#๐Ÿ”’ Task 1 help

37 messages ยท Page 1 of 1 (latest)

spark larkBOT
#

@inland geyser

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.

inland geyser
#

Heres my code

spark larkBOT
# inland geyser

Please react with โœ… to upload your file(s) to our paste bin, which is more accessible for some users.

sweet python
inland geyser
#

I plugged in 20 and 5 but it doesnt give the same result the professor has shown us in the assignment's directions

inland geyser
#

The examples don't look right when I pasted it on disc, heres a screenshot of it

noble wharf
# inland geyser

so first, walk through your code using the exapmle that doesnt work, 20 and 5

#

whats the first if statement doing?

inland geyser
#

So first I try to intialize my variables for the while loop

#

ignore the print statement

noble wharf
#

yeah but the first if statement you run into is this

    if add_stories%2 == 0:
        return 0
inland geyser
#

Im confused, what's wrong with it?

#

We were told to return 0 if we divided by it

noble wharf
#

thats a modulus its checking if the remainder of a division by 2 is 0

inland geyser
#

Oh

#

hm...

#

Well how do I fix that?

#

Should an if statement saying is pausesTaken == 0, return 0?

noble wharf
#

yeah

#

so thats one problem solved

inland geyser
#

Alright so now we gotta fix the while loop

noble wharf
#

yeah so what does the while loop do in each cycle of the loop

inland geyser
#

For some reason it returns nothing

#

But im trying to figure out where I went wrong.

noble wharf
#

yeah so count+=1 is good that makes sense, but then add_stories//2, you're just dividing add_stories by 2 but youre not storing the result anywhere

#

and lastly keep in mind that when you return count that stops the loop early

#

if you change those 2 lines it should be fixed

inland geyser
#

alright so I'll have to remove the return command then?

noble wharf
#

you have to move it so its not stopping the loop the first time the loop is run and only returning once count is the correct answer

inland geyser
#

Im gonna take a break and eat breakfast

noble wharf
#

alright good luck

spark larkBOT
#
Python help channel closed for inactivity

This help channel has been closed. 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.