Skip to content

Instantly share code, notes, and snippets.

@brainyfarm
Created August 8, 2016 10:00
Show Gist options
  • Save brainyfarm/7c63ca346766f648a9c224237cf21b58 to your computer and use it in GitHub Desktop.
Save brainyfarm/7c63ca346766f648a9c224237cf21b58 to your computer and use it in GitHub Desktop.
FreeCodeCamp: Mutations (Python)
"""
Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.
For example, ["hello", "Hello"], should return true because all of the letters in the second string are present in the first, ignoring case.
The arguments ["hello", "hey"] should return false because the string "hello" does not contain a "y".
Lastly, ["Alien", "line"], should return true because all of the letters in "line" are present in "Alien".
"""
def mutation(the_list):
for char in the_list[1]:
if the_list[0].lower().find(char.lower()) == -1:
return False
return True
print mutation(["floor", "for"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment