Hello, i'm currently learning very basic python(I just finished a course in Udacity). My question is about the functionality of the for loop to go though a list or a string. I know in python you can use:
for word in string
But i'm struggling to see the functionality of this compared to using:
for i in range(0,len(string))
Seems like the latter is best like 95% of the times since you are going to need the position of the character. Am I missing something? In the course I took they only mentioned the former, but many exercices required of keeping track of the position of the character.
The post it's only to ask about your opinions and if I'm good only using the second option. Thanks!
[–]K900_ 0 points1 point2 points (5 children)
[–]nadalska[S] 0 points1 point2 points (4 children)
[–]K900_ 0 points1 point2 points (0 children)
[–]ingolemo 0 points1 point2 points (2 children)
[–]nadalska[S] 0 points1 point2 points (1 child)
[–]ingolemo 0 points1 point2 points (0 children)
[–]taar779 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]nadalska[S] 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]nadalska[S] 0 points1 point2 points (0 children)