Skip to main content
7 events
when toggle format what by license comment
Jun 12, 2018 at 18:15 comment added Falsenames Not a python code here either... as evidenced by not knowing the super awesome shortcuts that @Graipher listed. The full stops are scrubbed out with the .isalpha bits. That will only return characters that are letters. And the string2 exception kicks out a false if a character shows up that is not in string1 at all.
Jun 8, 2018 at 18:10 history edited Falsenames CC BY-SA 4.0
added a more condensed version of the logic from Graipher
Jun 8, 2018 at 14:03 comment added Sinc Falsenames I'm not a Python coder. Why isn't the except: return false in the string2 handling going to cause your last example to fail because of the period? Also, what will happen if you put the period in the first string instead? Won't the x[c]=1 cause a failure?
Jun 8, 2018 at 8:21 comment added Graipher While I like the idea behind your proposed function, it's readability is not the best (not using PEP8, one-line variable names) and has some other problems (bare excepts). I would probably just compare two collections.Counter objects with Counter(filter(str.isalpha, map(str.lower, s1))) == Counter(filter(str.isalpha, map(str.lower, s2))).
Jun 7, 2018 at 23:17 comment added nemo Oh snap good point. . . you are right what if the strings are separated by spaced, have special characters etc all important factors to clarify before starting to thinking about the solution. Good catch !
Jun 7, 2018 at 22:56 review First posts
Jun 8, 2018 at 1:58
Jun 7, 2018 at 22:53 history answered Falsenames CC BY-SA 4.0