Python-programming-exercises icon indicating copy to clipboard operation
Python-programming-exercises copied to clipboard

line 1087

Open LastDance500 opened this issue 5 years ago • 1 comments

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)

LastDance500 avatar Aug 24 '20 03:08 LastDance500

Yes, either that or i can iterate over the indices of tp, keeping rest of the code unchanged : for i in range(len(tp))

nish-ant avatar Sep 04 '20 08:09 nish-ant