Skip to content

Instantly share code, notes, and snippets.

@aduartem
Last active August 29, 2016 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aduartem/ea3d3a98b429cbb95582 to your computer and use it in GitHub Desktop.
Save aduartem/ea3d3a98b429cbb95582 to your computer and use it in GitHub Desktop.
Python - Recursividad
#!/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