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)

2nd Jan 2021, 9:43 PM
Fredrik Holmquist
Fredrik Holmquist - avatar
7 Answers
0
The problem is in the if i in items==0: Instead put if i == 0:
2nd Jan 2021, 11:48 PM
Daniel Briceño
Daniel Briceño - avatar
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
2nd Jan 2021, 11:52 PM
Daniel Briceño
Daniel Briceño - avatar
2nd Jan 2021, 11:57 PM
Daniel Briceño
Daniel Briceño - avatar
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?
4th Jan 2021, 8:02 AM
Fredrik Holmquist
Fredrik Holmquist - avatar
0
Yes
4th Jan 2021, 7:39 PM
Daniel Briceño
Daniel Briceño - avatar
0
Task: improves my code. And do not enter my previous code until you find it improved because I already update it
4th Jan 2021, 7:43 PM
Daniel Briceño
Daniel Briceño - avatar
0
Thanks alot Daniel! 😊
4th Jan 2021, 8:22 PM
Fredrik Holmquist
Fredrik Holmquist - avatar