correct code
+9 −9 · 1 file changed
-
medium/06-string-scramble.py+9 −9
@@ -1,12 +1,13 @@ def StringScramble(str1,str2): - ll = (set(str1) & set(str2)) - # for n in ll: - # if n in str1 or str2: - # print 'f',n + lst = list(str1) - if len(ll ^ set(str2)) and len(ll ^ set(str1)): - return 'false' + for i in str2: + if i in lst: + lst.remove(i) + print lst + else: + return 'false' return 'true' """ @@ -19,7 +20,6 @@ otherwise return the string false. For example: if str1 is "rkqodlw" and str2 is "world" the output should return true. Punctuation and symbols will not be entered with the parameters. - """ # keep this function call here # to see how to enter arguments in Python scroll down @@ -30,8 +30,8 @@ print StringScramble("heloooolwrdlla","helloworld") print StringScramble("coamamaaqq","comma") print StringScramble("letrrkakaeaaaqq","letter") print StringScramble("aqwe","qa") -print StringScramble("yelowrqwedlk","yellowred") +print StringScramble("yelowrqwedk","yellowred") print StringScramble("cdore","coder") - +print StringScramble("win33er","winner") # Input = "cdore" & str2= "coder"Output = "true" # Input = "h3llko" & str2 = "hello"Output = "false" \ No newline at end of file