“Python brechen” Code-Antworten

Python während der Weiter

## When the program execution reaches a continue statement, 
## the program execution immediately jumps back to the start 
## of the loop.
while True:
    print('Who are you?')
    name = input()
    if name != 'Joe':
        continue
    print('Hello, Joe. What is the password? (It is a fish.)')
    password = input()
    if password == 'swordfish':
        break
print('Access granted.')
SkelliBoi

Beispiel für eine Break -Aussage in Python

while True:
    num = input("Enter the number: ")
    if num == "":
        break
    number = int(num)
    print("The square of the number ",number,"  is: ", number*number)
print("User entered a null string")
Outrageous Ostrich

Python -Pause

for i in range(5): # For loop
  if i == 3:
    break # Exits out of the for loop, even when not finished
  else:
    print(i)
    
number = 1
while number <= 5:
  if number == 4:
    break # Exits while loop
  else:
    print(number)
Ninja Penguin

Python brechen

# Use of break statement inside the loop

for val in "string":
    if val == "i":
        break
    print(val)

print("The end")
SAMER SAEID

Ähnliche Antworten wie “Python brechen”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen