list index out of range in simple Python script

前端 未结 6 1694
余生分开走
余生分开走 2021-01-24 12:53

I just started learning Python and want to create a simple script that will read integer numbers from user input and print their sum.

The code that I wrote is

         


        
6条回答
  •  遥遥无期
    2021-01-24 13:25

    script that will read integer numbers from user input and print their sum.

    try this :

    inflow = list(map(int, input().split(" ")))
    result = 0
    for i in inflow:
        result += i
    print(result)
    

提交回复
热议问题