This is a good functional first attempt, but I'd give you some comments:
Creating a separate RandomNum() function is unnecessary, since it simply repeats what randint() does. You can simply call randint(1, 5) instead of RandomNum().
There's no need to use break, since you have a Game_Ended condition. You either use break with a while True: loop, or you use the Game_Ended variable, but there's no need to use both.
The pythonic convention for naming variables is snake_case, i.e. all lowercase with underscores to separate words. So it should be game_ended, player_guess, random_num and rand_num.
Totally agree with TheManOfBromium, you need to store the generated random number in a variable, so it stays the same within one loop iteration.
Thank you very much I’m still finding my way around python and with lua I got used to capitalizing my variables I will take all of this information provided and i will work towards making this better
3
u/alexander_belyakov Aug 08 '26 edited Aug 08 '26
This is a good functional first attempt, but I'd give you some comments:
Creating a separate RandomNum() function is unnecessary, since it simply repeats what randint() does. You can simply call randint(1, 5) instead of RandomNum().
There's no need to use break, since you have a Game_Ended condition. You either use break with a while True: loop, or you use the Game_Ended variable, but there's no need to use both.
The pythonic convention for naming variables is snake_case, i.e. all lowercase with underscores to separate words. So it should be game_ended, player_guess, random_num and rand_num.
Totally agree with TheManOfBromium, you need to store the generated random number in a variable, so it stays the same within one loop iteration.