Hi, everyone.
I have a question about the following Python code. What I'm going to ask is a question about code with this structure in Python repeat
a = [i for i in features if i != alphabet]
In the repetition code above, the syntax for i in features if i!= alphabet makes sense.
But what is the i at the front for?
I don't quite understand.
python
a = [i for i in features if i != alphabet]
The above code is translated as follows:
This is what happens when you change the third step of the above translation to obtain i*2
.
a = [i*2 for i in features if i != alphabet]
Finally... Why i
? Since the iterator is called an iterator in English, it is i
after the first letter. That's just why most repetitions in most languages typically use i
.
© 2024 OneMinuteCode. All rights reserved.