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 Comparisons

Alternate responses to different names arent printing

first_name = input("What is your first name?   ")
print("Hello,", first_name)
if first_name == "Craig":
    print(first_name, "is learning Python")
elif first_name == "Maximiliane":
    print (first_name, "is learning in the community! Me too!")
else:
    age = int(input("how old are you?    "))
    if age <= 6:
        print("wow you're {}! If you're confident with your reading already...".format(age))
    print("You should totally learn Python, {}!".format(first_name))
print(first_name, "is learning python")

Mod Edit: Fixed code formatting. See comment for how to make your code fancy and readable in your posts.

Did you save your work first? Can you format your code using markdown?

rydavim
rydavim
18,814 Points

You can format your code in posts by using some special markdown.

```python

Your code here!

```

This is especially useful for Python, where some errors may be related to white-space.

rydavim
rydavim
18,814 Points

Your code appears to be working as expected for me. Can you elaborate on the issues you're having?

2 Answers

Steven Parker
Steven Parker
231,172 Points

Because it is not indented, that last "print" will be done in all cases. It looks like it was only intended for the "else" case, and for that it needs to be indented.

If that's not your issue, please describe it in a bit more detail.

Ryan Markey
seal-mask
.a{fill-rule:evenodd;}techdegree
Ryan Markey
Front End Web Development Techdegree Student 12,565 Points
first_name = input("What is your first name?   ")
print("Hello,", first_name)
if first_name == "Craig":
    print(first_name, "is learning Python")
elif first_name == "Maximiliane":
    print (first_name, "is learning in the community! Me too!")
else:
    age = int(input("how old are you?    "))
    if age <= 6:
        print("wow you're {}! If you're confident with your reading already...".format(age))
        print("You should totally learn Python, {}!".format(first_name))
        print(first_name, "is learning python")

I'm not entirely sure what your intention is with your code... but it works perfectly! You must remember to indent your code properly or python won't be able to understand, with the last three 'print' functions they all need to be indented with the same spacing beneath the 'if' statement for these actions to be executed when the code runs.