Reputation: 305
I'm writing a short program to take ten numbers and reprint them as a list but replacing those below a certain amount with zero. First, 'input' isn't working and prompting me to give the numbers. Second I'm getting 'TypeError: 'int' object not iterable' for the second 'for' loop in the main function. Any ideas?
amx = []
def validamount(amount, limit):
if amount >= limit:
return amount
else:
return 0
def main():
for i in 10:
amx.append(int(input()))
for i in 10:
print(validamount(amx[i], 5))
main()
Upvotes: 1
Views: 557
Reputation: 4580
You cannot iterate over a number, try:
for i in range(10):
refer to: https://docs.python.org/2/library/functions.html#range
Upvotes: 3
Reputation: 57630
for i in 10:
is the source of your error; it should be for i in range(10):
instead.
Upvotes: 2