python add users input to an empty list using a for loop

后端 未结 1 1759
既然无缘
既然无缘 2021-01-29 05:50

so I want to add users input to an empty list using this code

no_of_num=int(input(\'enter the number of numbers you would like to add\\n=\'))#this will store the         


        
相关标签:
1条回答
  • 2021-01-29 06:14

    @Ram Pandey is right add num instead if i try this, it works

    for i in range(0,no_of_num):
        num=int(input('enter the number\n='))
        list_of_num.append(num)
    print(sum(list_of_num))
    
    0 讨论(0)
提交回复
热议问题