for element in range(10): ... input_ages = int(input("\t\t\t\t\tNow please input their ages as well: ")) team_leader = max(input_ages)
input_ages
is a single integer that gets reassigned each loop iteration.
max(input_ages)
expects input_ages
to be a list for which to find the maximum value by iterating over it. Therefore you get 'int' object is not iterable
.
To do it correctly, initialize an empty list input_ages
before the loop, and then append the ages to that list in the loop:
input_ages = []
for element in range(10):
...
input_ages.append(int(input("\t\t\t\t\tNow please input their ages as well: ")))
team_leader = max(input_ages)
2
solved the error is ‘int’ object is not iterable, I am working on a small project in python that allows the user to input ten names and ten ages of students [closed]