Created
November 28, 2021 04:27
-
-
Save sinabigo/e7d4fd918ac4e874c8991179cee08685 to your computer and use it in GitHub Desktop.
any-amount-of-players number guessing game ## بازی حدس زدن تعداد بازیکنان
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
max_score=100 | |
max_scorer="" | |
while True: | |
print("Top score: %d by %s" % (max_score,max_scorer)) | |
name = input("what’s your name?") | |
print("hello %s" % name) | |
answer = random.randint(1,100) | |
guess=0 | |
n_guesses=0 | |
print("You are now playing the number guessing game v.1.4 whats your guess?") | |
while (guess != answer): | |
n_guesses=n_guesses+1 | |
guess = int(input("enter your guess num. %d: " % n_guesses)) | |
if guess == answer: | |
print("Yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay!") | |
break | |
elif guess < answer:print("Too low.") | |
elif guess > answer:print("Too high.") | |
if (n_guesses<max_score): | |
max_score=n_guesses | |
max_scorer=name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment