SimeonTs

SUPyF2 Functions-Exercise - 05. Palindrome Integers

Oct 8th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. """
  2. Functions - Exercise
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1728#4
  4.  
  5. SUPyF2 Functions-Exercise - 05. Palindrome Integers
  6.  
  7. Problem:
  8. A palindrome is a number which reads the same backward as forward, such as 323 or 1001.
  9. Write a function which receives a list of positive integers and checks if each integer is a palindrome or not.
  10. Print the results on the console
  11. The input will be a single string containing the numbers separated by comma and space ", "
  12.  
  13. Examples:
  14. Input:
  15. 123, 323, 421, 121
  16.  
  17. Output:
  18. False
  19. True
  20. False
  21. True
  22.  
  23. Input:
  24. 32, 2, 232, 1010
  25.  
  26. Output:
  27. False
  28. True
  29. True
  30. False
  31.  
  32. Hints:
  33. • Read more about palindromes: https://en.wikipedia.org/wiki/Palindrome
  34.  
  35. """
  36.  
  37.  
  38. def palindrome(string):
  39.     for each_string in [word for word in string.split(", ")]:
  40.         if each_string == each_string[::-1]:
  41.             print("True")
  42.         else:
  43.             print("False")
  44.  
  45.  
  46. palindrome(input())
Add Comment
Please, Sign In to add comment