“Break Python” Kode Jawaban

Python saat melanjutkan

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

Contoh pernyataan break di 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

Istirahat 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

Break Python

# Use of break statement inside the loop

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

print("The end")
SAMER SAEID

Jawaban yang mirip dengan “Break Python”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya