For loops in Python are easy 🔁

preview_player
Показать описание
#python #course #tutorial

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)
Рекомендации по теме
Комментарии
Автор

# 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)

BroCodez
Автор

bro's a gigachad, physically and mentally

Hamyto
Автор

Welp that made my understanding more clearer, at first I was on a course learning for loops and implementing it Into real situations like a website or software and I was confused but once I saw this it made the understanding of it easier thank you

Nk_Lifestyle
Автор

bro that's even better than yout 12-hour tutorial piece. I had a small doubts how range can be iterated but now I understand it!

stanislawignacy
Автор

Best explanation and easy to understand. Thank you!!

Engmau
Автор

Keep up the good work! You helped me out and now i understand more and better! Thank you

JamalDid
Автор

This stuff was confusing in my course and in my book. This really helped clear up some confusion. Thanks man!

ZenZangetsu
Автор

i just need to say thank you, i have a programming exam tomorrow and your videos are saving my life

Draurore
Автор

This episode is really interesting, keep it up!

senpaigt
Автор

Nice video shows methods to create a business..

SerapioSergiovich
Автор

thank you so much for helping. i understand you so well. <3

adamartinmusic
Автор

Thank you, that was such a straight forward explanation.

christinamammolito
Автор

i your videos just clear all my doughts . arigato gozaimasu !!

rebeccabreez
Автор

thank you i had watched alot of videos and couldnt understand, yet i understand now good day.

Dev_bhog
Автор

I was first confused at coding but ur explanation is marvelous i like how you teach programming

karnikkumarsingh
Автор

biggest gigachad because:

A) Amazing tutorial

B) Said tutorial is absolutely free

C) Flat out refuses donations and says no give to a charity

D) Has the gigachad picture in his pfp

edikblank
Автор

High quality content. You win me as a subscriber.

SukreLopezBeats
Автор

Can you guys imagine this legend made me master in python, and in school, students of my grade are just learning simple things of python

AmanNgmOP
Автор

Bro you are the best guy for programming

sameerjain
Автор

Thank u so much bro
Congratulation for 1M subscribers🥳

HsuMonMonThant