loops(python3)

francnstein

francnstein

Posted on April 22, 2020

loops(python3)

Sometimes, you need to perform code on each item in a list. This is called iteration, and it can be accomplished with a while loop and a counter variable.
For example:

words = ['hello', 'words', 'viggies', 'eggs']
counter = 0
max_index = len(words) - 1

while counter <= max_index:
word = words[counter]
print(word + '!')
counter = counter+1

sololearn

💖 💪 🙅 🚩
francnstein
francnstein

Posted on April 22, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Mastering Python the Right Way
python Mastering Python the Right Way

March 2, 2022

loops(python3)
python loops(python3)

April 22, 2020