Trying to come up with python anagram function

后端 未结 7 2008
梦谈多话
梦谈多话 2021-01-23 14:02

What I\'m trying to do is if I have a list like:

[\"lime\", \"mile\", \"liem\", \"tag\", \"gat\", \"goat\", \"math\"]

I want to write a functio

7条回答
  •  北恋
    北恋 (楼主)
    2021-01-23 14:07

    def does_string_contain(big_word, small_word) :
        list_string = list(big_word)
        for char in small_word:
            if char in list_string:
                list_string.pop(list_string.index(char))
            else:
                return False
        for char in small_word:
            if char in list_string:
                return False
        return True
    

提交回复
热议问题