✨ Add some easy one
This commit is contained in:
17
ScientificExpedition/verify-anagrams.py
Normal file
17
ScientificExpedition/verify-anagrams.py
Normal file
@@ -0,0 +1,17 @@
|
||||
def verify_anagrams(first_word, second_word):
|
||||
first_word = first_word.replace(" ", "").lower()
|
||||
second_word = list(second_word.replace(" ", "").lower())
|
||||
for letter in first_word:
|
||||
if letter in second_word:
|
||||
second_word.remove(letter)
|
||||
else:
|
||||
return False
|
||||
return len(second_word) == 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# These "asserts" using only for self-checking and not necessary for auto-testing
|
||||
assert isinstance(verify_anagrams("a", 'z'), bool), "Boolean!"
|
||||
assert verify_anagrams("Programming", "Gram Ring Mop") == True, "Gram of code"
|
||||
assert verify_anagrams("Hello", "Ole Oh") == False, "Hello! Ole Oh!"
|
||||
assert verify_anagrams("Kyoto", "Tokyo") == True, "The global warming crisis of 3002"
|
Reference in New Issue
Block a user