SimeonTs

SUPyF2 Lists-Advanced-Lab - 03. Palindrome Strings

Oct 9th, 2019
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. """
  2. Lists Advanced - Lab
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1730#2
  4.  
  5. SUPyF2 Lists-Advanced-Lab - 03. Palindrome Strings
  6.  
  7. Problem:
  8. Write a program that receives on the first line words separated by a space and a searched palindrome on the second.
  9. Print all the palindromes on the first line. Print all the occurrences of the searched palindrome in the format:
  10. "Found palindrome {count} times"
  11.  
  12. Examples:
  13. Input:                                  Output:
  14. wow father mom wow shirt stats          ['wow', 'mom', 'wow', 'stats']
  15. wow                                     Found palindrome 2 times
  16.  
  17. hey how you doin? lol                   ['lol']
  18. mom                                     Found palindrome 0 times
  19. """
  20. strings = [word for word in input().split()]
  21. print([word for word in strings if word == word[::-1]])
  22. special_word = input()
  23. print(f"Found palindrome {len([word for word in strings if word == special_word])} times")
Add Comment
Please, Sign In to add comment