I have two strings like s1='fly,dream';s2='dream,fly'
I want the s1 equals to s2.
The code I tried is:
def Isequal(m,n):
s1=m.split(',') s2=n.split(',') s1.sort() s2.sort()
if s1 == s2:
print 'Equal'
else:
print s1,s2
Note:s1 may be equal to s2. Then
def Isequal(m,n):
s1=m.split(',')
s2=n.split(',')
if s1 == s2.reverse() || s1 == s2:
print 'Equal'
else:
print s1,s2
Is this code right? I there something to improve?
s1to equals2, you can just dos1 = s2. Then they will be equal. (I think you wanted to know if the order of the words, separated by commas, of each string is the inverse of the other.)