0
my program doesn't work SOLVED
hi everybody, I was doing some exercises when I found this one: Write a Python program which accepts a sequence of comma-separated numbers from user and generate a list with those numbers. Output : List : ['3', ' 5', ' 7', ' 23'] so I wrote: list=[] i=0 while i<=3: list.append(input("type number")) i=i+1 print(list) but it doesn't work :/ Can you help me undersatnd why?
4 Antworten
+ 2
Put print(list) out of the loop.
+ 4
It sounds more like the expected input should be all numbers input separated by a comma at once, not inputting each number individually.
I.E.
Input:
1,2,3,4,5
Output:
['1', '2', '3', '4', '5']
In which case;
print(input().split(','))
+ 2
This would work if you run it from the terminal on your computer, but not sololearn which will only accept input once.
+ 1
thank you very much everybody. IT WORKS!!!!!!!!