for-else

names = ["Alice", "Bob", "Charlie", "Diana"]

search_name = "Charlie"

for name in names:
    if name == search_name:
        print(f"{search_name} found!")
        break
else:
    # This part runs if the name was not found
    print(f"{search_name} not found in the list.")
Charlie found!
def is_prime(number):
    if number <= 1:
        return False
    for i in range(2, int(number**0.5) + 1):
        if number % i == 0:
            print(f"{number} is not a prime number.")
            break
    else:
        # This part runs if the number has no divisors other than 1 and itself
        print(f"{number} is a prime number.")

is_prime(11)  # This should print that 11 is a prime number.
is_prime(10)  # This should print that 10 is not a prime number.
11 is a prime number.
10 is not a prime number.