break
- Belki bir şart sağlandığı zaman döngüden aniden çıkmak istersek, bunu
breakile sağlıyoruz.
breakkomutunu gördüğümüz yerde döngüden çıkıyoruz.
for i in range(10):
if i == 3:
breakprint(i)
0 1 2
x = 0
while x < 10:
print(x)
x += 1
if x == 3:
break
0 1 2
continue
- Bazen döngülerde bir şart sağlandığında bir sonraki iterasyondan devam etmek isteyebilirim. Bunu
continueile sağlayacağız.
continuekomutu ile karşılaşıldığı zaman, döngünün bir sonraki iterasyonuna geçilir.
for i in range(10):
if i == 3:
continueprint(i)
0 1 2 4 5 6 7 8 9
x = 0
while x < 10:
x += 1
if x == 3:
continue
print(x)
1 2 4 5 6 7 8 9 10
Quiz
Answer the questions to check your understanding.
This lesson includes a short quiz.
Lesson discussion
Swap insights and ask questions about Python Temel
Be the first to start the discussion
Ask a question or share your thoughts about this lesson.