Video of looping through strings

in the following code:

     for letter in fruit:

How does computer know that the word ‘letter’ is the letter that we know? because we haven’t defined anything then How can python print the letters of banana?

It doesn’t, you can put whatever you wanted instead of “letter”, you could have put just a single letter and it would work. In this loop, the computer is assigning a variable called “letter” for each letter in your word and reading it. Name doesn’t matter as long as you have put some kind of value :slight_smile:



See this post to find the backtick on your keyboard.

Ohk…got it.
Thank you so much

1 Like

I strongly advise you follow the FCC curriculum on Scientific Computing with Python, which is represented by the free course Python for Everybody by Dr. Charles Severance and one of the things he puts as sideline emphasis is naming conventions, or the lack of such, when it comes to computers