Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def is_palindrome(word):
- return word == word[::-1]
- sequence = input().split()
- palindrome_to_find = input()
- found_palindromes = []
- for word in sequence:
- if is_palindrome(word):
- found_palindromes.append(word)
- print(found_palindromes)
- palindrome_count = found_palindromes.count(palindrome_to_find)
- print(f'Found palindrome {palindrome_count} times')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement