Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialmustafa alfakeeh
374 Pointswhy is it` not working right? the if stetment does not work when i put mustafa
name = input("what is your name ").upper()
print ('Hello',name)
if name=='mustafa' or name=='mustafa':
print('hello {} have nice day'.format('Mustafa'))
else:
print('Hello {} let\'s be a friend'.format(name))
print ('you goona be all right ')
3 Answers
Austin Lester
Courses Plus Student 11,272 PointsHello Mustafa,
Your if statement is checking to see if your input is equal to 'mustafa'. When you add 'upper()' to your input you are changing it to 'MUSTAFA' so your print statement inside the if statement is not run. 'mustafa' is not equal to 'MUSTAFA'. See code below.
name = input("What is your name?").upper()
print('Hello, ' + name.title())
if name == 'MUSTAFA':
print('Hello {} have a nice day'.format(name.title()))
else:
print("Hello {} let's be a friend".format(name.title()))
print('You gonna be all right')
Austin Lester
Courses Plus Student 11,272 PointsNo there really wasn't any particular reason. I just typically don't think about doing it with a comma. I do like that way better now.
Hrithik Sharma
6,090 PointsI updated your code little bit see if you can find your error https://teamtreehouse.com/workspaces/38275112#
Timothy Villaraza
394 PointsTimothy Villaraza
394 PointsOn line 3, is there any particular reason why you wrote
print('Hello, ' + name.title())
instead of
print("Hello,", name.title())
They gave the same output, however I don't know if you were following Mustafa's format, using your own formatting preference, or following snake case.