Something went wrong. Try again.
CMU Coding Bootcamp
Something went wrong. Try again.
12345678910111213141516171819202122232425def sameChars(s1: str, s2: str) -> bool: """Check if two strings have the same characters regardless of order or count.""" if not (isinstance(s1, str) and isinstance(s2, str)): return False c1 = list(set(s1)) c2 = list(set(s2)) c1.sort() c2.sort() print(c1, c2) return c1 == c2
print("Testing sameChars()...", end="")assert sameChars("abc", "bac") == Trueassert sameChars("aaaaabbbbbbccccc", "abc") == Trueassert sameChars("abc", "ba") == Falseassert sameChars("ba", "abc") == Falseassert sameChars("AAAAAAaaaa", "Aa") == Trueassert sameChars("NNN", "n") == Falseassert sameChars("123", "123") == Trueassert sameChars("", "a") == Falseassert sameChars("", "") == True# assert sameChars(14, "14") == False # this check passes but if I don't comment it I get an editor warning since I've typed the functionprint("Passed!")