AlexSwearingen
AlexSwearingen

Reputation: 37

Random number indexing past inputs Python

I'm having a little bug in my program where you give the computer a random number to try to guess, and a range to guess between and the amount of guesses it has. After the computer generates a random number, it asks you if it is your number, if not, it asks you if it is higher or lower than it. My problem is, if your number is 50, and it generates 53, you would say "l" or "lower" or something that starts with "l". Then it would generate 12 or something, you would say "higher" or something, and it might give you 72. How could I make it so that it remembers to be lower than 53?

Upvotes: 1

Views: 57

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798676

Create 2 variables that contain the lowest and highest possible values. Whenever you get a response, store it in the appropriate variable. Make the RNG pick a value between the two.

Upvotes: 3

Related Questions