-
-
Save parzibyte/f72137fe200e9fdb807578d995ff3e18 to your computer and use it in GitHub Desktop.
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
""" | |
https://parzibyte.me/blog | |
""" | |
def invertir_numero(n): | |
numero = 0 | |
while n != 0: | |
numero = 10*numero+n % 10 | |
n //= 10 | |
return numero | |
def capicua(numero): | |
return numero == invertir_numero(numero) | |
# Probar | |
numeros = [11, 20, 123, 9889, 2811, 1801, 777, 12321, ] | |
for numero in numeros: | |
es_capicua = capicua(numero) | |
print(f"El número {numero} es capicúa? {es_capicua}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment