python string comparison function

The Amateur Coder
def mystrcmp(x,y):
   print (x.lower(),y.lower())
   if(str(x.lower()) == str(y.lower())):
         print ("true")
   else:
         print ("false")

mystrcmp("python", "pTHYON")

This code gives incorrect output, it should give True but gives False

Palash Bauri

You Can Use the following script to really get a true output

def mystrcmp(x,y):
        x, y = str(x),str(y)
    print(x.lower(),y.lower())
    if x.lower() == y.lower():
        print ("true")
    else:
        print ("false")

mystrcmp("python", "pYTHON")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive