IndexError: Replacement index 2 out of range for positional args tuple - help

Joined
Oct 14, 2022
Messages
1
Reaction score
0
Hello.

I've been trying for days to fix this error, but to no avail.

This is the code:

Python:
def secret_formula(started):
    jelly_beans = started * 500
    jars = jelly_beans / 1000
    crates = jars / 100
    return jelly_beans, crates, jars

start_point = 10000

jelly_beans, jars, crates = secret_formula(start_point)

print("With a starting point of: {}".format(start_point))
print("We'd have %d jelly beans, %d jars, and %d crates." % (jelly_beans, jars, crates))

start_point = start_point / 10

print("We can also do that this way:")
print("We'd have {0} jelly beans, {2} jars, and {1} creates.".format(secret_formula(start_point)))

It is throwing the error when print("We'd have {0} jelly beans, {2} jars, and {1} creates.".format(secret_formula(start_point))) is called.

Any help would be greatly appreciated.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top