DEV Community

Cover image for loops(python3)
francnstein
francnstein

Posted on

1 1

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

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay