int object is not iterable?

前端 未结 11 834
天命终不由人
天命终不由人 2020-12-01 11:19
inp = int(input(\"Enter a number:\"))

for i in inp:
    n = n + i;
    print (n)

... throws an error: \'int\' object is not iterable<

11条回答
  •  离开以前
    2020-12-01 11:50

    Don't make it a int(), but make it a range() will solve this problem.

    inp = range(input("Enter a number: "))
    

提交回复
热议问题