April 8, 2024, 9:11 a.m. | MercyMburu

DEV Community dev.to



What are loops?



They can be termed simply as a way to repeatedly execute some code➿.


For example:



planets= ['mercury','venus','earth','mars','jupyter','saturn','uranus','neptune']
for planet in planets:
print(planet,end='')

# The end='' overrides the \n behavior and instead adds a space ('') after each planet name

output: Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune


The for loop specifies:


The variable names to use in this case, ‘planet’

The set of values to loop over ‘planets’

You use the word ‘in’ to link …

beginners behavior code earth example iteration jupiter jupyter list lists loops magic mars mercury planet python space the end

Software Engineer for AI Training Data (School Specific)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Python)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Tier 2)

@ G2i Inc | Remote

Data Engineer

@ Lemon.io | Remote: Europe, LATAM, Canada, UK, Asia, Oceania

Artificial Intelligence – Bioinformatic Expert

@ University of Texas Medical Branch | Galveston, TX

Lead Developer (AI)

@ Cere Network | San Francisco, US