Course Content
Learn Python from Scratch
Learn Python from Scratch
for loop (2/5)
Remember data types we learned previously? for
loop can easily iterate over some of them. For example, you can easily iterate over a string to get all symbols from it.
# iterate over string s = "small string" for i in s: print(i)
Or over list
# iterate over list l = [1, [2,3], 4, "wow"] for i in l: print(i)
The same applies to tuples.
Task
Given list people
. Using for
loop, extract every single item from it.
Thanks for your feedback!
for loop (2/5)
Remember data types we learned previously? for
loop can easily iterate over some of them. For example, you can easily iterate over a string to get all symbols from it.
# iterate over string s = "small string" for i in s: print(i)
Or over list
# iterate over list l = [1, [2,3], 4, "wow"] for i in l: print(i)
The same applies to tuples.
Task
Given list people
. Using for
loop, extract every single item from it.
Thanks for your feedback!
for loop (2/5)
Remember data types we learned previously? for
loop can easily iterate over some of them. For example, you can easily iterate over a string to get all symbols from it.
# iterate over string s = "small string" for i in s: print(i)
Or over list
# iterate over list l = [1, [2,3], 4, "wow"] for i in l: print(i)
The same applies to tuples.
Task
Given list people
. Using for
loop, extract every single item from it.
Thanks for your feedback!
Remember data types we learned previously? for
loop can easily iterate over some of them. For example, you can easily iterate over a string to get all symbols from it.
# iterate over string s = "small string" for i in s: print(i)
Or over list
# iterate over list l = [1, [2,3], 4, "wow"] for i in l: print(i)
The same applies to tuples.
Task
Given list people
. Using for
loop, extract every single item from it.