Last active
August 29, 2016 03:35
-
-
Save aduartem/ea3d3a98b429cbb95582 to your computer and use it in GitHub Desktop.
Python - Recursividad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
def jugar(intento = 1): | |
print "\n¿Cuanto es 2 x 2?" | |
respuesta = int(raw_input("> ")) | |
if respuesta != 4: | |
max = 3 | |
if intento < max: | |
print "\nRespuesta incorrecta. Intentalo nuevamente, te quedan " + str(max - intento) + " intento(s)" | |
intento += 1 | |
jugar(intento) | |
else: | |
print "\nPerdiste :(" | |
else: | |
print "\nFelicidades, ganaste :)" | |
print "Tienes un máximo de 3 intentos para contestar esta sencilla pregunta:" | |
jugar() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment