0
votes
seniornames =[]
paidornot =[]
for i in range("senior"):
 print("Please enter the name of the Senior Citizen", i+1);
 seniornames.append (input())
 print(seniornames)

there is an error saying - File "/Users/rheasethi/Documents/Task 2 pre release.py", line 37, in for i in range("senior"): TypeError: 'str' object cannot be interpreted as an integer

What should I do?

1
What do you expect range("senior") to do? range takes an integer and returns a range up to that integer. range(5) being 0, 1, 2, 3, 4, range("senior") is…? (If you have a variable called senior and would like to pass it instead of a string, that’s range(senior), but that information isn’t in your question so it’s just a guess.) - Ry-♦
for i in range("senior"): print("Please enter the name of the Senior Citizen", i+1); /// range() can only be used with intger ..' - Ankur Jyoti Phukan

1 Answers

0
votes

range(start, stop[, step])

The arguments must be plain integers. If the step argument is omitted, it defaults to 1. If the start argument is omitted, it defaults to 0.

From i+1,it seems that you need i to be an integer,so maybe what you want is this:

seniornames =[]
paidornot =[]
for i in range(len("senior")):
    print("Please enter the name of the Senior Citizen", i+1)
    seniornames.append (input())
    print(seniornames)

Or

for i in range(5):
    print("Please enter the name of the Senior Citizen", i+1)
    seniornames.append (input())
    print(seniornames)