“Python saat loop break” 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

Python saat loop break

import random

# This loop will run forever unless we break it
while True:
    # Generate a random int between 1 and 10
    random_integer = random.randint(1, 10)
    print(random_integer)
    # Stop the loop if the random int is 5
    if random_integer == 5:
        break
Outrageous Oyster

Jawaban yang mirip dengan “Python saat loop break”

Pertanyaan yang mirip dengan “Python saat loop break”

Lebih banyak jawaban terkait untuk “Python saat loop break” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya