Created
January 18, 2019 18:12
-
-
Save parzibyte/66dd97eee5174e0d059d3da0792f86dc to your computer and use it in GitHub Desktop.
Validar entero en Python created by parzibyte - https://repl.it/@parzibyte/Validar-entero-en-Python
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
""" | |
Validar si una cadena o variable es un entero | |
en Python | |
@author parzibyte | |
""" | |
# Nota: la variable podría venir de cualquier lado, en | |
# este caso el usuario la escribe | |
posible_numero = input("Escribe algo y te diré si es un entero: ") | |
try: | |
entero = int(posible_numero) | |
print("Lo que escribiste es un entero") | |
except ValueError: | |
print("Lo que escribiste NO es un entero") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment