Hey there, this looks like a class assignment, until you confirm otherwise, we cannot help you
ay, we can’t help in potential HW XD
I won’t give him code, but I can point him where he needs to go to learn it
Can you please show me where to go to learn it?
I found this Documention page which looks good to learn:
Assuming this is python…
First you need to get a random number, you can do that via the
random library using
randint()documentation here: random — Generate pseudo-random numbers — Python 3.11.1 documentation
A while loop is pretty simple, it runs while the given statement is true, so you can just do
while True to run forever. Use
break to exit the loop.
To get input from the user use the built in function
input() which returns a string. You will have to convert that string to an integer which can you do with
Use an if statement to check if the number the user inputted is equal to your random number. If it is, break the loop.
Outside the loop, you can thank them for being correct.
Hmm? @AnthonyPetrillo never asked for a random number.