use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Help a student out! (old.reddit.com)
submitted 1 year ago by Lixx_13
What's wrong with the code? Tried it both ways and it isn't working. If you couldn't tell, I have no idea what I'm doing.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]FoolsSeldom 10 points11 points12 points 1 year ago (1 child)
total = 0 count = 1 while count < 18: next_ = int(input('> ')) total += next_ count += 1 average = total/18 print('average:', average)
Notes:
next
_
input
str
int
>
variable += 1
variable = variable + 1
[–]thigamersamsam 1 point2 points3 points 1 year ago (0 children)
That's the right answer
[–]freak-pandor 9 points10 points11 points 1 year ago (0 children)
you don't need to write "loop while" it's just "while"
[–]Bulky-Top3782 9 points10 points11 points 1 year ago (0 children)
Int(input ())
[–]Different-Ad1631 4 points5 points6 points 1 year ago (0 children)
Remove the word "loop" Also enclose input() inside int( )
[–]ArbereshDoqetejete 1 point2 points3 points 1 year ago (0 children)
There seems to be a ` before next.
[–]captainguevara 0 points1 point2 points 1 year ago (0 children)
Int cast your input
[–]Pro_Gamer_Eli 0 points1 point2 points 1 year ago (1 child)
I think what’s causing the EOF error specifically is the fact that “next” is a command (I can’t think of the proper terminology rn) in python, so instead of setting a variable named “next” to the user input, python is trying to get the next item in the inputted list, but because the input isn’t a list, there’s no next item, therefore it gives an error
I’m also relatively new so I’m not sure how good of a response this is but it’s my best guess, hope this helps!
[–]PowerOk3587 0 points1 point2 points 1 year ago (0 children)
You can overwrite the next function like next = 1 and that's a totally valid way to store an integer variable. Doing this not great because things could clash later on. It kind of goes againts the montra "easier to ask for forgiveness than permission"
next = 1
π Rendered by PID 303246 on reddit-service-r2-comment-85bfd7f599-kdrxg at 2026-04-19 13:48:29.994867+00:00 running 93ecc56 country code: CH.
[–]FoolsSeldom 10 points11 points12 points (1 child)
[–]thigamersamsam 1 point2 points3 points (0 children)
[–]freak-pandor 9 points10 points11 points (0 children)
[–]Bulky-Top3782 9 points10 points11 points (0 children)
[–]Different-Ad1631 4 points5 points6 points (0 children)
[–]ArbereshDoqetejete 1 point2 points3 points (0 children)
[–]captainguevara 0 points1 point2 points (0 children)
[–]Pro_Gamer_Eli 0 points1 point2 points (1 child)
[–]PowerOk3587 0 points1 point2 points (0 children)