Splinterlands Hangman with holoz0r - a development in Python

in Splinterlands2 years ago

A few days ago, I said that I was starting to learn Python. I am doing exactly that.

image.png

I have published this game on GitHub, and while it has many issues, Please remember that I am at day 7 of my journey to learning Python.

I might come back to this project as I get better, and improve upon it; but for the time being, it is a fun little project built out from the skeleton of the course I am following.

If you're a crazy experienced developer, please poke holes in my code and tell me why and how it can be improved. I'd love to know!

import random
from hangmanart import *
from hangmanwords import word_list

end_of_game = False
chosen_word = random.choice(word_list)
word_length = len(chosen_word)
lives = 6
print(logo)
#Testing code
# print(f'Pssst, the solution is {chosen_word}.')

display = []
for _ in range(word_length):
    display += "_"

while not end_of_game:
    guess = input("Guess a letter: ").lower()

    for position in range(word_length):
        letter = chosen_word[position]
        if letter == guess:
            display[position] = letter 

    if guess not in chosen_word and lives >0:
      lives -= 1
      print(f"You have {lives} lives left.")
      if lives == 0:
        end_of_game = True
        print("You Lose!")
        print(f"The Correct answer was {chosen_word}.")
    print(f"{' '.join(display)}")

    if "_" not in display:
      end_of_game = True
      print("You win.")

    print(stages[lives])

image.png

Until next time...


Want more holoz0r and Splinterlands?



If you want to see my Splinterlands antics and rants live, Find me on Twitch

If you prefer sleeping in your designated time zone, go watch replays on YouTube.

If you haven't started playing Splinterlands, you should do that immediately. It's very good fun.

Go and watch me open season rewards and packs on YouTube!


Want more content from me?

Witness my futile efforts to play my Steam Game collection in alphabetical order.

Are you aware that I love photography? Check out my work in a collection.


Thanks as always for your time!

Sort:  
Loading...

Fun game and great job.

Thanks mate! Need to get a lot better at coding to make some more creative things! :D