Using for loops in Python?

Joined
Mar 29, 2023
Messages
10
Reaction score
1
Hello eveyone!

I'm still trying to learn Python3 and i am making progress albeit slowly lol.

I have been trying to learn about 'for loops' but for some reason i can't get them to work the way i want.
So here's an example of a for loop i have been trying to execute.

Code:
# I open a terminal and type python3 then:
>>> word = "elephant"
>>> for letter in word:
...          print (letter)
...

Could anyone tell me why the above code work doesn't work?
 
Joined
Aug 6, 2023
Messages
5
Reaction score
0
It's probably an indentation error. Did you encounter something like "indentation doesn't match" when trying to run that code? That could be the problem. Your indentation have to be consistent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top