Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Else | While Loops: Essentials
Python Loops

bookElse

else can be used not only inside if-else statements but after loops. Instructions after else statement are executing after exiting the loop but not because of break. If you leave the loop because of break, else instructions are skipped.

1234
while condition: inctructions... else: instructions...
copy
Uppgift

Swipe to start coding

For the given list list_, check if all elements in it are positive. Print YES or NO. Use break to leave the loop if a non-positive number appears.

Lösning

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 5
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

close

Awesome!

Completion rate improved to 6.25

bookElse

Svep för att visa menyn

else can be used not only inside if-else statements but after loops. Instructions after else statement are executing after exiting the loop but not because of break. If you leave the loop because of break, else instructions are skipped.

1234
while condition: inctructions... else: instructions...
copy
Uppgift

Swipe to start coding

For the given list list_, check if all elements in it are positive. Print YES or NO. Use break to leave the loop if a non-positive number appears.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

close

Awesome!

Completion rate improved to 6.25
Avsnitt 2. Kapitel 5
single

single

some-alt