Advertisement
elcocodrilotito

Políndromos

Oct 26th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. #Escribir una función que compruebe si una cadena "s" es un políndromo (lo que comúnmente se conoce como capicúa)
  2. def capicua(s):
  3.     a=0
  4.     for i in range(len(s)):
  5.         if s[i]==s[len(s)-1-i]:
  6.             a=a+1
  7.     if a==len(s):
  8.         return "true"
  9.     else:
  10.         return "false"
  11.  
  12. s=input("Dame cadena: ")
  13. print(capicua(s))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement