diff --git a/guessinggame.py b/guessinggame.py index 141ce11..560fc07 100644 --- a/guessinggame.py +++ b/guessinggame.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +# !/usr/bin/env python3 import random @@ -6,14 +6,13 @@ tries = 0 win = False # setting a win flag to false +name = input("Hello, what is your username? ") -name = input("Hello, What is your username?") - -print("Hello" + name + "." ) +print("Hello", name + ".", ) question = input("Would you like to play a game? [Y/N] ") -if question.lower() == "n": #in case of capital letters is entered - print("oh..okay") +if question.lower() == "n": + print("Have a nice day") exit() if question.lower() == "y": print("I'm thinking of a number between 1 & 10") @@ -22,10 +21,16 @@ tries = tries + 1 if guess == number: win = True # set win to true when the user guesses correctly. + elif guess > 10: + print("Learn to count to 10") + exit() + elif guess < 1: + print("Learn to count to 10") + exit() elif guess < number: print("Guess Higher") elif guess > number: print("Guess Lower") # if win is true then output message -print("Congrats, you guessed correctly. The number was indeed {}".format(number)) -print("it had taken you {} tries".format(tries)) +print("Congrats", name + ",", "you guessed correctly. The number was indeed {}.".format(number)) +print("It only took {} tries.".format(tries))