forked from OmkarPathak/pygorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanagram.py
More file actions
22 lines (19 loc) · 807 Bytes
/
anagram.py
File metadata and controls
22 lines (19 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Author: OMKAR PATHAK
# Created On: 17th August 2017
from collections import Counter
def is_anagram(word, List):
'''
ANAGRAM: An anagram is direct word switch or word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase, using all the original letters exactly once
We are taking a word and a list. We return the anagrams of that word from the given list and return the list of anagrams else return empty list
'''
word = word.lower()
anagrams = []
for words in List:
if word != words.lower():
if Counter(word) == Counter(words.lower()):
anagrams.append(words)
return anagrams
def get_code():
""" returns the code for the current class """
import inspect
return inspect.getsource(is_anagram)