python int () function
El siguiente código muestra error si un decimal(ej. 49.9) se envía anext
variable. ¿Puedes decirme por qué? Por queint()
lo convierte en un entero?
next=raw_input("> ")
how_much = int(next)
if how_much < 50:
print"Nice, you're not greedy, you win"
exit(0)
else:
dead("You greedy bastard!")
Si no usoint()
ofloat()
y solo usa:
how_much=next
entonces se mueve a "else" incluso si doy la entrada como49.8
.