I have tried everything i can still doesn't work. Please any help would be appreciated.
Please i have been able to allow it generate one hint, but i need it to generate 3 different hints the 3 different times the user presses 0 for the hint.
I have it give the hint even OR odd. i need it to give extra 2 hints.
- Generates a random number between 1 and 100.
- Allows the user 10 tries to guess what the number is.
- Validates the user input (if user-input >100 or user-input<0) then this is invalid input and should not cost the user to lose any tries.
- Gives feedback for each time the user makes a guess. The feedback tells the user whether the number entered is bigger, smaller, or equal to the number generated (and exits the program).
- Tells the user if they lost after he/she consumes all the 10 tries. Gives the user 10 tries to guess the number. If the user exhausts the 10 ties. The user loses.
- After 2 unsuccessful tries, the program should start offering hints for the users (by having the user input the number 0).
- Each hint should be generated within a function of its own.
- Each hint will cost the user two tries (the program should indicate this to the user)
- The user is allowed a max of 3 hints only.
- The program should randomly pick which hint it is going to use and display to the user.
(example of a hint is : 1- The number is bigger than or equal the square of some X (X is an integer and is the largest integer square that is less than the user input))
Here is my program so far:
import randomguessesTaken = 0print('WELCOME! What is your name?')myName = input()number = random.randint(1, 100)print('Hello, ' + myName + ', I generated a number between 1 and 100.')unsuccessful_tries = 0hint_taken = 0while guessesTaken < 10: if unsuccessful_tries > 1 and hint_taken<3: print('Press 0 to get hint') need_hint = int(input()) if need_hint == 0: hint_taken += 1 guessesTaken += 1 if number%2==0: print('The Generated number is an EVEN number') else: print('The Generated number is an ODD number') print('Take a guess.\t%d Attempts Left'%(10 - guessesTaken)) #10-guessTaken gives the number of tries left guess = input() guess = int(guess) #validating the user's input if guess >100 or guess<0: continue guessesTaken = guessesTaken + 1 if guess < number: print('Your guess is too low.') if guess > number: print('Your guess is too high.') if guess == number: break unsuccessful_tries+=1if guess == number: guessesTaken = str(guessesTaken) print('Good job, ' + myName + '! You guessed my number in ' + guessesTaken + ' guesses!')if guess != number: number = str(number) print('Nope. The number I was thinking of was ' + number)