我所有的功能都是單獨工作的,當我把它們放在一起時,它會斷開,永遠不會停止做任何事情,我只是很累,你會介意幫助嗎?請Python Hang子手根本沒有工作
當前的錯誤,我越來越有:轉讓前
局部變量引用。
它要求每個決定兩次。
圖形無法正常工作。
__author__ = 'Rodrigo Cano'
#Modulos
import random
import re
#Variables Globales
intentos = 0
incorrectos = 0
palabras = [(1,"disclosure"),(1,"thenational"),(1,"foals"),(1,"skepta"),(1,"shamir"),(1,"kanye"),
(1,"fidlar"),(1,"lcdsoundsystem"),(1,"lorde"),(1,"fkatwigs"),(1,"miguel"),(1,"rtj"),
(1,"boniver"),(1,"strokes"),(2,"vaporwave"),(2,"witchouse"),(2,"shoegaze"),(2,"memerap"),
(2,"paulblartisoursaviour"),(3,"glockenspiel"),(3,"aesthetic"),(3,"schadenfreude"),
(3,"bonvivant"),(3,"swag"),(3,"jue")]
palabra_a_jugar = ''
Array_Palabra = []
Nuevas_Letras = ''
letras = []
Vidas = 0
i = len(Array_Palabra)
#Funciones
def Definir_Palabra():
eleccion = int(input("Bienvenido, que categoria quiere usar:"
'\n'"1 - Musica que Escuche Mientras Lo Hacia"
'\n'"2 - Generos Musicales"
'\n'"3 - Palabras Pretenciosas"))
palabras_escogidas = [i for i in palabras if eleccion in i ]
palabra_a_jugar = str(palabras_escogidas[random.randint(0,len(palabras_escogidas))].__getitem__(1))
Array_Palabra = len(palabra_a_jugar) * ['*']
return palabra_a_jugar, Array_Palabra
def Letras_En_Palabra(letra):
letras = [i for i, x in enumerate(palabra_a_jugar) if x == letra]
for i in range (0, len(letras)):
Array_Palabra[letras] = letra
return letras,Array_Palabra
def Letras_Jugadas(letra):
for i in range(0,len(Nuevas_Letras)):
Nuevas_Letras = re.findall(letra,Nuevas_Letras[i])
if Nuevas_Letras != []:
return 1
return Nuevas_Letras
def Eleccion():
Choice = input("Quiere Jugar?")
if Choice == 'si':
Choice = 1
elif Choice == 'no':
Choice = 0
return Choice
def hangman_graphic(vidas):
if vidas == 0:
print (" ")
print (" ")
print (" ")
print (" ")
print (" ")
print (" ")
elif vidas == 1:
print ("________ ")
print ("| | ")
print ("| 0 ")
print ("| ")
print ("| ")
print ("| ")
elif vidas == 2:
print ("________ ")
print ("| | ")
print ("| 0 ")
print ("| ")
print ("| ")
print ("| ")
elif vidas == 3:
print ("________ ")
print ("| | ")
print ("| 0 ")
print ("| / ")
print ("| ")
print ("| ")
elif vidas == 4:
print ("________ ")
print ("| | ")
print ("| 0 ")
print ("| /| ")
print ("| ")
print ("| ")
elif vidas == 5:
print ("________ ")
print ("| | ")
print ("| 0 ")
print ("| /|\ ")
print ("| ")
print ("| ")
elif vidas == 6:
print ("________ ")
print ("| | ")
print ("| 0 ")
print ("| /|\ ")
print ("| / ")
print ("| ")
else:
print("________ ")
print ("| | ")
print ("| 0 ")
print ("| /|\ ")
print ("| /\ ")
print ("womp womp")
# Juego
Choice = Eleccion()
def Juego(Choice):
vidas = 0
i = len(Array_Palabra)
while Choice == 1:
print(Definir_Palabra())
while i != 0 :
tiro = str.lower(input("adivine una letra"))
if Letras_Jugadas(tiro) != 1:
Nuevas_Letras = Nuevas_Letras + tiro
letras = Letras_En_Palabra(tiro)
if Letras_Jugadas(tiro) != []:
i = len(letras) - 1
print("Letras Utilizadas",Nuevas_Letras)
print(Letras_En_Palabra(tiro))
print(hangman_graphic(vidas))
else:
Vidas = Vidas + 1
print(hangman_graphic(vidas))
print("WROOOONG")
print("Letras Utilizadas",Nuevas_Letras)
if Vidas == 7:
i = 0
else:
print("Letra ya Juagada",Nuevas_Letras)
Choice = Eleccion()
Juego(Choice)
您需要了解[mcve]。這是太多的代碼,你沒有給我們任何實際的回溯。 –
我認爲你需要看到我所指的功能,它前面的#juego部分是唯一錯誤的部分 –