Python-programming-exercises
Python-programming-exercises copied to clipboard
line 1087
the if in the loop maybe wrong?
tp=(1,2,3,4,5,6,7,8,9,10)
li=list()
for i in tp:
if i%2==0: #<-----tp[i] should be i
li.append(i)
tp2=tuple(li) print (tp2)
Yes, either that or i can iterate over the indices of tp, keeping rest of the code unchanged : for i in range(len(tp))