str1="hello" for stringElement in str1: print("str1","=",stringElement)
Strings are arrays in python and they are represented like this.
Now I want to understand how the for loop is working here.
My dry run-:
for h in str1 print h
for e in str1 print e
and so on till o...
This is what I have read about python for loop from a book called python power.
My confusion is that-:
1) How can I see array index 0 when h is being printed
2) How does python knows to increment array index by 1 after the end of each for loop? I heard strings are iterables in python and that it means that objects that are capable of returing its members one at a time. . But I am not very clear what do they really mean here in this case. So some guidance will be really valuable.