def every_three_nums(start):
new_lst = []
if start > 100:
return []
else:
for i in range(start, 103, 3):
new_lst = new_lst[i]
return new_lst
#Uncomment the line below when your function is done
print(every_three_nums(91))
for i in range(start, 103, 3):
new_lst = new_lst[i]
new_list[i] is always out of range because new_list is empty. It also depends on itself which seems kind of wrong. This line basically says “empty list” = ith element of “empty list” which is out of range for i = 91. There is no 91th element. I hope I understood this correctly.
I solved this with append, however:
def every_three_nums(start):
lst = []
for i in range(start, 101, 3):
lst.append(i)
return lst
pay attention to 101 and not 103 otherwise you will get result up to 102! (Except, you add the if statement, like you did.)