How do I fix TypeError: 'int' object is not iterable?

后端 未结 3 1572
孤街浪徒
孤街浪徒 2020-11-30 13:01

I am trying to write a program that allows you to enter the number of students in a class, and then enter 3 test grades for each student to calculate averages. I am new to

3条回答
  •  自闭症患者
    2020-11-30 13:16

    Numbers can't be iterated over. What you're probably looking for is the range function, which will create a sequence of numbers up to the number you want:

    for number in range(1, students + 1):

    The reason I added + 1 there is because the second argument to range is exclusive.

提交回复
热议问题