/ Published in: Python

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#juego de adivinar un numero import random intentos=0 print"escribe tu nombre para jugar" minombre = raw_input() secreto = random.randint(1,20) print minombre ,", estoy pensando un numero entre el 1 y 20." while intentos < 6: print "adivinalo" #tab antes de print numero_jugador = raw_input() numero_jugador = int(numero_jugador) intentos = intentos+1 if numero_jugador < secreto: print"tu numero es menor que el numero secreto" if numero_jugador > secreto: print "tu numero es mayor que el numero secreto" if numero_jugador == secreto: break if numero_jugador== secreto: intentos == str(intentos) print "correcto",minombre,"has adivinado mi numero en",intentos,"intentos" if numero_jugador != secreto: secreto = str(secreto) print "has perdido!el numero era",secreto
Comments
