00:00:00 iterate forwards
00:01:39 iterate backwards
00:02:15 step
00:02:44 iterate over a string
00:03:26 continue
00:04:19 break
00:04:35 conclusion
for loops = execute a block of code a fixed number of times.
You can iterate over a range, string, sequence, etc.
------------- EXAMPLE 1 -------------
for x in range(1, 11):
print(x)
------------- EXAMPLE 2 -------------
for x in reversed(range(1, 11)):
print(x)
print("Happy New Year!")
------------- EXAMPLE 3 -------------
for x in range(1, 11, 2):
print(x)
------------- EXAMPLE 4 -------------
credit_card = "1234-5678-9012-3456"
for x in credit_card:
print(x)
------------- CONTINUE -------------
for x in range(1, 21):
if x == 13:
continue
else:
print(x)
------------- BREAK -------------
for x in range(1, 21):
if x == 13:
break
else:
print(x
Nesta página do site você pode assistir ao vídeo on-line For loops in Python are easy 🔁In python tutorial duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário NitCode 13 Novembro 2022, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 12 vezes e gostou 3 espectadores. Boa visualização!