What is the purpose of `index +=1`?

In the example given for While Loops—

dog_breeds = [‘bulldog’, ‘dalmation’, ‘shihtzu’, ‘poodle’, ‘collie’]

index = 0
while index < len(dog_breeds):
print(dog_breeds[index])
index += 1

What is the purpose of—

index += 1

We need to be sure that i is constantly changing (increasing) so that the test condition eventually fails, otherwise the loop will run indefinitely (infinite loop). We wouldn’t want that.

6 Likes

dog_breeds = [‘bulldog’, ‘dalmation’, ‘shihtzu’, ‘poodle’, ‘collie’]
for dog_breeds
i got an error is If i used a single ’ quote.

it work with " double quote.

Sorry I still dont get this can you elaborate a bit further please.