leetcode(5),Valid Anagram(python)

question:

Given two strings s and t, write a function to determine if t is an anagram of s.

For example,
s = "anagram", t = "nagaram", return true.
s = "rat", t = "car", return false.

代码如下:

def ValidAnagram(string1,string2):
    lstr1 = list(string1)
    sstr1 = lstr1.sort()
    lstr2 = list(string2)
    sstr2 = lstr2.sort()
    print lstr1,lstr2
    if lstr1 == lstr2:
        return True
    else:
        return False


你可能感兴趣的:(LeetCode,python)