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 trial

Python Python Basics Types and Branching If, Else and Elif

If and else statements are both true

Hi,

if I input yahya both "is learning python" and "you should definetly learn python" statements appear in the console, could anyone please explain to me where I went wrong?

Code:

First_name = input("Hello, What's your name?")

if First_name == "yahya":

print(First_name, " is learning python")

elif First_name == "gleb":

print (First_name, " is learning python")

else:

print ("you should definetly learn python {}".format(First_name))

print ("have a good day {}".format (First_name))

// thank you!

boi
boi
14,242 Points

It seems like an indentation issue, make sure your indentation of else is proper.

1 Answer

Steven Parker
Steven Parker
231,198 Points

As suggested by boi, an indentation error could cause your issue.
For us to be able to see the code as it really is, use Markdown formatting when posting to the forum.

it seems that workspace just didn't work, I ran the code again today without modification and it worked :)