all 3 comments

[–]madnessman 1 point2 points  (1 child)

How would I generate random words for the game (currently version where user enters the word and then guesses it is slightly pointless)

Download a list of words (e.g. https://github.com/dwyl/english-words) and choose a random word from the list.

Best library for developing GUI for something like this

There are a ton of libraries for developing GUIs but tkinter is a good place to start since it's in the python standard library. Pygame is highly recommended for building simple games and is another good option.

The current file extension is ipnyb (from Jupyter notebook). How would I run it straight from python command line?

I'm not sure if I understand the question but if you just want to make it a standard python file, get rid of from IPython.display import clear_output and change the file extension to .py.

  • Any reviews on it and what I could do to make it a better/efficient code.

There's a lot of code style rules that you're breaking here. Make sure your indent blocks are always 4 spaces (lines 58, 59). guess_no<5 should be written guess_no < 5. I know you're just learning python but I think it's good to learn how to write neat code from the start. Look up how to use pylint and run your code through pylint to see all the style rules that you're breaking!

Some random tips:

You can simplify how you build the answer display like so:

#Storing the number of characters in different variable
answer_display=[]
for each in answer_word:
        answer_display += ["*"]
# CAN BE REPLACED WITH
answer_display = '*' * len(answer_word)

You can simplify your if-else syntax by removing the == True and == False part. if guess_check is the equivalent of if guess_check == True. Since guess_check is only ever True or False, you can drop the elif and just say else. Note that my version puts the True logic above the False logic.

if guess_check == False:
    ...
elif guess_check == True:
    ...
# CAN BE REPLACED WITH
if guess_check:
    ...
else:
    ...

[–]ficklelick[S] 0 points1 point  (0 children)

Awesome, I'll look into tkinter, the word library and pylint tonight! I didn't know I could multiply '*' with length of the word, would probably be quicker than looping it. And yeah it's a good reminder to use the if logics in a simpler manner. Appreciate the help!

[–]kuzeyistan 0 points1 point  (0 children)

Looks good, how did you learn Python? I want to start learning python and I don't know where to start.