Preparing git repo for final project
This commit is contained in:
28
problems/pset4/game/game.py
Normal file
28
problems/pset4/game/game.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import random
|
||||
|
||||
|
||||
def main():
|
||||
n = -1
|
||||
while n < 1:
|
||||
try:
|
||||
n = int(input("Level: "))
|
||||
except (TypeError, ValueError):
|
||||
continue
|
||||
random.seed()
|
||||
n_to_guess = random.randint(1, n)
|
||||
guess = -1
|
||||
while n_to_guess - guess != 0:
|
||||
try:
|
||||
guess = int(input("Guess: "))
|
||||
except (TypeError, ValueError):
|
||||
continue
|
||||
if guess == n_to_guess:
|
||||
print("Just right!")
|
||||
if guess < n_to_guess:
|
||||
print("Too small!")
|
||||
if guess > n_to_guess:
|
||||
print("Too large!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user