Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Python
name = input('what is your name: ')

if name is "Bucky":
    print("Hi Bucky")
elif name is "Lucy":
    print("Hi Lucy")
elif name is "Sammy":
    print("Hi Sammy")


What I have tried:

i have tried to use c++ , and Java. If i cant do this in these , what language can i use to do this with.
Posted
Updated 13-Feb-18 15:07pm
v2
Comments
phil.o 11-Feb-18 19:03pm    
Doing what exactly? Write a program which only accepts 3 names and says Hi <name>; or else does not do anything?

Try using equality operator (==) instead of object comparison (is)
Python
...
if name == 'Bucky':
   print("Hi Bucky")
elif name == 'Lucy':
   print("Hi Lucy")
...
 
Share this answer
 
v2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900