#๐Ÿ”’ need help with a task (very new to coding)

23 messages ยท Page 1 of 1 (latest)

formal hatch
#

please help me with this task

harsh boneBOT
#

@formal hatch

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

formal hatch
#

if I write 3, the program prints out 6

fierce jay
#

you are using a <= to check if the sum is equal to the limit, thus even when it is 3 (1 + 2) it evaluates that 3 <= 3, it is equal so it continues

limber plume
#

the order in which you run things is really important. You should be doing divert += 1 at the end of the loop

#

right now you're increasing it, and then totalling it. This means you skip the first number

#

Bzale is correct too about the loop condition

formal hatch
#

oh

fierce jay
wide turtle
#

you set the 1 before the loop so it kind of checks out

#

per the instruction, the loop should stop when it's at least equal

#

but your while loop doesn't stop at equal

formal hatch
#

how do I make it stop at equal?

fierce jay
#

just remove the = sign

formal hatch
#

ok

limber plume
formal hatch
#

do I move divert back?

fierce jay
formal hatch
#

thanks

fierce jay
#

np

harsh boneBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.