How to traverse list,tuple and string | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

How to traverse list,tuple and string

Function

8th Nov 2019, 4:23 PM
Lakshmi Prasanna
1 Resposta
+ 5
You can iterate over list, tuple or string by using a for loop. lst = [1,2,3,6,2,5] for i in lst: # do something with i the for loop picks one item in list in each iteration. This item is stored in i. The loop will continue until no more items can be found in lst.
8th Nov 2019, 4:44 PM
Lothar
Lothar - avatar