Created
August 8, 2016 10:00
-
-
Save brainyfarm/7c63ca346766f648a9c224237cf21b58 to your computer and use it in GitHub Desktop.
FreeCodeCamp: Mutations (Python)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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