Skip to content

guess_number_game.py #20

Description

@Leo121378

guess_number_game.py

import random

def guess_number():
number = random.randint(1, 100)
print("1-ээс 100 хүртэл тоо таах тоглоом эхэллээ!")

attempts = 0
while True:
    try:
        guess = int(input("Тоо оруулна уу: "))
        attempts += 1
        if guess < number:
            print("Их тоо оруулна уу.")
        elif guess > number:
            print("Бага тоо оруулна уу.")
        else:
            print(f"Баяр хүргэе! Таны таасан тоо: {number}")
            print(f"Та {attempts} оролдлогоор зөв таалаа.")
            break
    except ValueError:
        print("Тоо оруулах ёстой шүү!")

if name == "main":
guess_number()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions