-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCode.txt
More file actions
36 lines (30 loc) · 857 Bytes
/
Code.txt
File metadata and controls
36 lines (30 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# AlexCrider - CIS261 - GuessingGame #
import random
def display_title():
print("Guess the number!")
print()
def play_game(LIMIT):
number = random.randit(1, LIMIT)
print(f"I'm thinking of a number from 1 to {LIMIT}\n")
count = 1
guess = int(input("Your guess: "))
while (guess != number):
if guess < number:
print("Too low.")
count += 1
elif guess > number:
print("Too high.")
count += 1
guess = int(input("Your guess: "))
print(f"You guessed it in {count} tries.\n")
def main():
display_title()
again = "y"
while again.lower() == "y":
LIMIT = int(input("Enter the limit: "))
play_game(LIMIT)
again = input("Would you like to play again? (y/n): ")
print()
print("Bye!")
if __name__ == "__main__":
main()