0
[solved] Python Codeplayground 27.4
Hi, New at this I get EOF error running below code. Anyone who can help out? Also, the print at the end only print the first input (when I tried just to print the list...) Thanks! items = [] while True: n = int(input()) items.append(n) for i in items: # startloop over list if i in items == 0: # checklist break #print(i) i = i + 1 # add 1 print(items)
7 Respuestas
0
The problem is in the if i in items==0:
Instead put if i == 0:
0
Because the for loop already places the value of the item in i.
Remember the compiler here read all the inputs at the same time.
https://code.sololearn.com/cQvBGj6yt3Fv/?ref=app
0
Reminds me of your code.
https://www.sololearn.com/discuss/2446038/?ref=app
0
Thanks Daniel a lot for the help! 2 things,
1) I don't really get the reason to start off with the u variable?
2) Is there a way not to write out the 0? To break when "user" input a zero?
0
Yes
0
Task:
improves my code.
And do not enter my previous code until you find it improved because I already update it
0
Thanks alot Daniel! 😊