“Briser Python” Réponses codées

Python tout en continuant

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

Exemple de déclaration de pause dans 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

Pause python

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

Briser Python

# Use of break statement inside the loop

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

print("The end")
SAMER SAEID

Réponses similaires à “Briser Python”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code