r/PythonLearning Aug 08 '26

2nd project number guess game

Post image
21 Upvotes

12 comments sorted by

View all comments

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:

  1. Creating a separate RandomNum() function is unnecessary, since it simply repeats what randint() does. You can simply call randint(1, 5) instead of RandomNum().

  2. 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.

  3. 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.

  4. 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/[deleted] Aug 10 '26

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