Click here to Skip to main content
15,438,393 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I started this game as a project as I just began learning python. the problem is I don't know how to make the 2D graphics appear every time the player makes a wrong guess. here is the code

Python
import random

def update(word,letter):
    global answer
    output = ""
    for i in range(len(word)):
        if (word[i].lower()== letter.lower() ):
            output += letter.lower()
        else:
            output += answer[i]
        
    return output
Guess_list = ["london","Angel","Technology","Innovation","Understanding","Server","Intent","Distance","Time","Computer"]
User = str(input("Enter your Name: "))
random_value = random.randint(0, len(Guess_list))
size = len(Guess_list[random_value])
answer = "-"*size
print(answer)

for i in range (size):
    guess = str(input("Guess Word: "))

    if guess.lower() in Guess_list[random_value].lower():
        answer = update(Guess_list[random_value],guess)
        print(answer)
    else:
        print("wrong")
        print("________   ")
        print("|      |   ")
        print("|          ")
        print("|          ")
        print("|          ")
        print("|          ")

    if( answer.find("-") == -1):
        break


What I have tried:

I tried this:
Python
if guess.lower() in Guess_list[random_value].lower():
      answer = update(Guess_list[random_value],guess)
      print(answer)
  else:
      print("wrong")
      print("________   ")
      print("|      |   ")
      print("|          ")
      print("|          ")
      print("|          ")
      print("|          ")
Posted
Updated 19-May-18 21:47pm

1 solution

Python
if guess.lower() in Guess_list[random_value].lower():

Why are you using random_value here? You need to compare the entered word with every word in your list.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900