0
For ... In
I learn the lesson on that function, I understand the general concept but when I fall on a For ... In code portion, I have a lot of difficulties for read it. Maybe I think and I read the For ... In the wrong way, I don't know. How do you read this For... In ? Do you have an image way for reading it ? Thanks for your return guys !
2 Respuestas
+ 4
A for loop in Python works on a container type:
A list, dict, set, range, string or really anything else with multiple elements that can be iterated over.
Let me give a few examples with pseudo code that may give you some intuition of how to read it:
for book in bookshelf:
read(book)
(This means: Take every book from the bookshelf one by one and read them.)
for task in textbook:
do(task)
for word in vocabulary:
repeat(word)
If you want to read more about the specifics (beyond the basics), look here:
https://code.sololearn.com/cSdiWZr4Cdp7/?ref=app
0
So in bookshelf, who is a list, a tuple or others, there is a list of title's book. With your code on For loop, I understand that I can chose any name (Maybe it is that part that was my understanding problem !).
but the read do what on the code ? I understand the print who print all the book but the read ? ...
Thanks for your help HonFu !