Welcome to the Python forum,
A small script like yours does not have to be a function.
See the following link for use of a while loop. http://www.pythonforbeginners.com/contro...hile-loops
Seed the value outside of the loop, and then loop until an answer is obtained. Use an input() statement to get the guess from the user.
Additional items to consider after you are successful:
a. What if the user types in something other than a number?
b. What if the user wants to give up?
Please let us know if you need additional help.
Lewis
A small script like yours does not have to be a function.
See the following link for use of a while loop. http://www.pythonforbeginners.com/contro...hile-loops
Seed the value outside of the loop, and then loop until an answer is obtained. Use an input() statement to get the guess from the user.
Additional items to consider after you are successful:
a. What if the user types in something other than a number?
b. What if the user wants to give up?
Please let us know if you need additional help.
Lewis
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00