Checkpoint 7.5.1.
- 0
- Yes, idx goes through the odd numbers starting at 1. o is at position 4 and 8.
- 1
- o is at positions 4 and 8. idx starts at 1, not 0.
- 2
- There are 2 o characters but idx does not take on the correct index values.
How many times is the letter o printed by the following statements?
s = "python rocks"
idx = 1
while idx < len(s):
print(s[idx])
idx = idx + 2