Python Exercise 3: Solution

Code file as described in the video

# no of guesses 9
# print no of guesses left
# No of guesses he took to finish
# game over

print("Number of guesses is limited to only 9 times: ")
while (number_of_guesses<=9):
    guess_number = int(input("Guess the number :\n"))
    if guess_number<18:
        print("you enter less number please input greater number.\n")
    elif guess_number>18:
        print("you enter greater number please input smaller number.\n ")
        print("you won\n")
        print(number_of_guesses,"no.of guesses he took to finish.")
    print(9-number_of_guesses,"no. of guesses left")
    number_of_guesses = number_of_guesses + 1

    print("Game Over")


zadrain at 2019-06-23 09:30:09 says
n=9 number_of_guesses=1 print("you have only 5 guesses") while(number_of_guesses<=5): guess_number= int(input("guess the number :\n")) if guess_number<9: print("your guess is too low like your energy.\n ") elif guess_number>9: print("your guess is too high like my energy,\n") else: print("you won \n") print(number_of_guesses,"no. of guesses you took to finsh") break print(9 - number_of_guesses,"no. of guesses left") number_of_guesses +=1 if(number_of_guesses>9): print("game over")
ahmedraza at 2019-06-23 09:30:09 says