Get a list of numbers as input from the user

前端 未结 17 1134
生来不讨喜
生来不讨喜 2020-11-21 22:26

I tried to use raw_input() to get a list of numbers, however with the code

numbers = raw_input()
print len(numbers)

the input

17条回答
  •  天涯浪人
    2020-11-21 23:25

    Another way could be to use the for-loop for this one. Let's say you want user to input 10 numbers into a list named "memo"

    memo=[] 
    for i in range (10):
        x=int(input("enter no. \n")) 
        memo.insert(i,x)
        i+=1
    print(memo) 
    

提交回复
热议问题