So, was just trying to see if I could figure out a way to get it to print the index value of not only the first "o" character, but also the second, so the output would clearly have to be 4, 8.
string = "Python for Beginners"
x = "o"
for x in string:
print (string.index (x))
My reasoning being that for every character equal to "o" in the string, it would give me its specific index count. Instead, it gave me this as an output
0
1
2
3
4
5
6
7
4
9
6
11
12
13
14
5
5
12
9
19
So other than not doing what I thought it would, I've spent most of the past hour trying to figure out the logic that got me that output but alas, being a noob, I couldn't figure it out for the life of me. I'd be interested in a solution on how to get it to count multiple instances of the same character, but even more interested in understanding exactly what happened to give me that output. Just can't figure it out. Cheers all