Hey there, this looks like a class assignment, until you confirm otherwise, we cannot help you 
1 Like
ay, we can’t help in potential HW XD
1 Like
I won’t give him code, but I can point him where he needs to go to learn it
2 Likes
Can you please show me where to go to learn it?
2 Likes
I found this Documention page which looks good to learn:
https://python101.pythonlibrary.org/chapter5_loops.html
1 Like
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 int()
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.
1 Like
Hmm? @AnthonyPetrillo never asked for a random number.
2 Likes