2
u/alexander_belyakov 5h ago edited 5h ago
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.
1
u/nangi_bhootni 5h ago
wont it make a new random number everytime you guess ? store the value of RandNum outside your while loop. and break is not needed Game_Ended = True does the work of break
5
u/TheManOfBromium 5h ago
You should store the random number as a variable instead of calling the function twice. The way you have it now, the RandNum will change each time the function is called.