0

I'm just starting to learn python and I am having some issues in comparing strings. I tried to look around but even after trying "==" and "is" and "eq()", my program still does not work.

I am used to working in Java, am I missing some sort of logic? Here is my code:

name = "John Smith"
name2 = name.lower
lowerName = name.lower

if name2 is lowerName:
    print("it is the same name") #this is never outputted
Nicole K
  • 3
  • 5

1 Answers1

0

You need to call the lower() function and use the == when comparing strings (since you are comparing the values, not the identities of the objects)

name = "John Smith"
name2 = name.lower()
lowerName = name.lower()

if name2 == lowerName:
    print("it is the same name")
Victor
  • 2,864
  • 1
  • 12
  • 20