Guest User

Untitled

a guest
Jan 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. """
  2. Validar si una cadena o variable es un entero
  3. en Python
  4.  
  5. @author parzibyte
  6. """
  7. # Nota: la variable podría venir de cualquier lado, en
  8. # este caso el usuario la escribe
  9. posible_numero = input("Escribe algo y te diré si es un entero: ")
  10. try:
  11. entero = int(posible_numero)
  12. print("Lo que escribiste es un entero")
  13. except ValueError:
  14. print("Lo que escribiste NO es un entero")
Add Comment
Please, Sign In to add comment