0

I am new to programming and using Python 3.5. When ever I run the following code it skips my if and elif statement and goes straight to else after entering input values that should run in the if or the elif lines of code (ie input entered is chris or sam). I don't understand why that is considering that all values are strings.

Here is my code:

name = input('What is your name?\n')
name = name.lower()

if name is 'chris':
    print('Hi Chris!')
elif name is 'sam':
    print('Hi Sam!')
else:
    print('Who are you?')

Thanks in advance :)

vaultah
  • 44,105
  • 12
  • 114
  • 143

1 Answers1

0

You should be using == not is. Is tests whether one object is the same type as another (if value is None for e.g).

marienbad
  • 1,461
  • 1
  • 9
  • 19