0
Good morning, I’ve been trying to make a mini game, where I insert the words in the variable WORDS and the same type the name randomly, so far Ok. But I wanted to change and I’m not able to do what I want, because I can’t find a way to do the same (I started studying programming last weekend). Follows the code:
import random
WORDS = ("palavra1", "palavra2", "palavra3")
word = random.choice(WORDS)
correct = word
champions = ""
while word:
position = random.randrange(len(word))
champions += word[position]
word = word[:position] + word[(position + 1):]
print("")
print("A palavra é:", champions)
guess = input("Nome: ")
while guess != correct and guess != "":
print("Essa não é a palavra")
guess = input("A palavra é: ")
if guess == correct:
print("Você acertou\n")
input("\n\nPressione Enter para sair. Versão 1.0")
What I wanted to change, I tried to make the result of the variable "word" pull a hint from a list and insert this hint after the person has made a mistake.
palavra1 = ["dica1","dica2","dica3"]
palavra2 = ["dica1","dica2","dica3"]
palavra3 = ["dica1","dica2","dica3"]
Example: print("That’s not the word") print("Tip:", dica1,".")
I imagine you got confused, but I think you can understand.
WORDSdefines a list of words that will be drawn.wordis the word drawn.championsis an anagram ofword. The value is displayedchampions, so that the user tries to get the word right,correct. The program keeps ordering a new word until the user gets it right. Now you want a hint to appear when the user gets it wrong. Question: Each diva should be displayed only once or they can repeat themselves and always show a hint when the user misses the word?– Woss
Always show a new tip when it misses, I put a repeat, but I did not put here in the code of the site, the person will have five chances, if you miss the five, lose.
– R. Souza
And there will be five tips?
– Woss
Yes, there will be five tips, I put only three as an example, but there will be five.
– R. Souza