- 1

How to compare two strings in python inside the characters example: input1 :xy and input 2:xyz output: z

Compare strings

24th Sep 2022, 3:44 PM
N G Johnson
N G Johnson - avatar
3 Respostas
+ 1
# You could use sets x = 'abc' y = 'abcf' print(set(x) - set(y)) print(set(y) - set(x)) print(set(y) ^ set(x)) # are you looking for differences or symmetric differences?
24th Sep 2022, 4:04 PM
Lisa
Lisa - avatar
0
Looking for comparing the characters in the string..Lisa
24th Sep 2022, 4:45 PM
N G Johnson
N G Johnson - avatar
0
> Looking for comparing the characters in the string.. This doesn't answer my question. Are you trying to find as substring in a string? Use the "in" operator.
24th Sep 2022, 5:31 PM
Lisa
Lisa - avatar