Day 039 - Project Hangman

import random,os, time

listOfWords = ["british", "suave", "integrity", "accent", "evil", "genius", "Downton"]
wordpicked = []
lives = 6 
wordChosen = random.choice(listOfWords)



while True:
    time.sleep(2)
    os.system("clear")
    print("🎮Hangman🎮")
    letter =  input(" choose a word: ").lower()
  
    if letter in listOfWords:
      print("You have tried that before")
      continue

    wordpicked.append(letter)

    if letter in wordChosen:
      print("You have found the correct letter.")
    else:
      print("Uh huh, not the correct one! Try again")
      lives -=1

NOTE: Anyone could help me with the drawing / visual of hangman while losing lives .

It’s not too good but you can use turtle graphics (A python library) the code import turtle t = turtle.Turtle t.color('red') t.forward(50) t.right(90) will shoe you the basics you can make the color white and go back over it when the input is wrong. (t.right turns right not move right.)

1 Like

can anyone help me with my problem of the letters showing from up to down instead of left to right?

import random
listofwords = [“british”, “suave”, “integrity”, “accent”, “evil”, “genius”, “downton”]
chosenword= random.choice(listofwords)
letterpicked=
counter=6
while True:
letterasked= input("please input a character ").lower()
if letterasked in letterpicked:
print("you have tried that one before ")
else:
letterpicked.append(letterasked)
if letterasked in chosenword:
print ("correct ")
elif letterasked not in chosenword:
counter -=1
print(f"no, its not in the word, you have {counter} try remaining ")
allletters = True
print()
for i in chosenword:

if i in letterpicked:
  print(i, end="")
  

else: 
  print("_", end="")
  allletters= False
  
  if counter <=0:
    print("you have ran out of tries ")
    print(f"the correct answer is {chosenword} ")
    break

if allletters:
print(f" you have won the game with {counter} tries left")
break

Hi @alirezayazdanit can you post a link to your Repl please?

https://replit.com/@alirezayazdanit/day-39-problem?v=1

What’s the issue?

im really sorry but that issue has been fixed,
how do i make the guessed word separated form the “please input a character” ?

Do you mean something like this:

______
please input a character: g

g_____
please input a character: s

g____s
please input a character: 

And so on?

yes, exactly like that

Try this:

...
for i in chosenword:
  if i in letterpicked:
    print(i, end="")
  else:
    print("_", end="")
    allletters = False
  # this will add a new line
  print()
...