Answers for "how to find palingrams python"

1

how to find palingrams python

"""
Program:
 Python program to find anagrams in a list of strings
"""
from collections import Counter

def get_anagrams(input_string_list, test_string): 
   
   print("*******************")
   print("input_string_list = ", input_string_list)
   print("*******************\n")

   # Find the list of anagrams in the strings    
   out_string_list = list(filter(lambda x: (Counter(test_string) == Counter(x)), input_string_list)) 

   # Print the list of anagrams in the strings 
   print("*******************")
   print("out_string_list = ", out_string_list)
   print("*******************\n")

def Driver(): 
   input_string_list = ['Python', 'Program', 'Machine', 'yPtnoh', 'Learning']
   test_string = "ntoyPh"
   get_anagrams(input_string_list, test_string)

if __name__=="__main__": 
   Driver()          # call Driver() function
Posted by: Guest on November-25-2020

Python Answers by Framework

Browse Popular Code Answers by Language