- import random
- def guessing_game():
- print("Welcome to the Guessing Game!")
- print("I'm thinking of a number between 1 and 100.")
- print("Try to guess the number.")
- secret_number = random.randint(1, 100)
- attempts = 0
- while True:
- guess = int(input("Enter your guess: "))
- attempts += 1
- if guess < secret_number:
- print("Too low! Try again.")
- elif guess > secret_number:
- print("Too high! Try again.")
- else:
- print(f"Congratulations! You guessed the number in {attempts} attempts.")
- break
- guessing_game()
Tools
- Sandbox
- Paste Code
- Snippets
- Generators
- Checks
- Convertors
[text] guessing game
Viewer
Editor
Share
Do you find this tool useful? Then share it with your friends or colleagues. This will help us to make our free web tools better.
You can edit this paste and save as new:
Information about embedding
In order to embed this content into your website or blog, simply copy and paste one of the codes provided below.
1. JavaScript Embedding (shows full code, full height depending on amount of lines in paste)
<script src="https://wtools.io/code/embed-js/bNuU"></script>
2. Iframe Embedding (you can set the frame height by adding the CSS value 'height:100px;' for example)
<iframe src="https://wtools.io/code/embed-iframe/bNuU" style="border:none;width:100%"></iframe>