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 The Solution

Problems with print and .format

Step 1

Ask the user for their name and the year they were born.

name = input("What is your name? "),
age = int(input("What year were you born? "))

Step 2

Calculate and print the year they'll turn 25, 50, 75, and 100.

twentyFive_years = 25
print("{} in", (age + twentyFive_years), "you will be 25.".format(name))
print("{}".format(name), "in", age + (twentyFive_years * 2), "you will be 50")
print("{}".format(name), "in", age + (twentyFive_years * 3), "you will be 75")
print("{}".format(name), "in", age + (twentyFive_years * 4), "you will be 100")

Step

If they're already past any of these ages, skip them.

The four print lines where ive tried (as you can see) to get a good result returns instead as follows:-
{} in 1999 you will be 25. (Tried here to make a change )
('Jason',) in 2024 you will be 50
('Jason',) in 2049 you will be 75
('Jason',) in 2074 you will be 100

Now his solution isn't basic at all!!! I'm new to this however i'm still stuck with my little learning code, in JavaScript this is easy with literals but here it's crazy hard I'm finding python is less forgiving. Can anyone help with MY code NOT the solution code, please and thank you.

2 Answers

The line name = input("What is your name? "), creates a tuple since it has a comma at the end, so the value of name becomes ("Jason",) rather than "Jason". Try removing the , or using name[0] to get the first value in the tuple.

A very big thank you, I didn't see that. Much appreciated.