Affiliate link

Python - Loops

Python has two primitive loop commands,

for loop

A for loop is used for iterating over a sequence (list, tuple, dictionary, set, or string).

language = ["JavaScript", "Python", "Go"]
for x in language:
    print(x)

while loop

while loop execute a set of statements as long as a condition is true.

i = 1
while i < 5:
    print(i)
    i += 1
Affiliate link
Affiliate link
Advertisment
WP Engine
Fiverr
Get Surfshark VPN