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 trialLucie Richard
1,172 PointsProblem with task 3 Python Basics
I'm unable to do task 3 :'( and I've no idea how to have the right answer ! I don't understand...
age = int(23)
days = int(23*52*7)
summary =
3 Answers
Andreas cormack
Python Web Development Techdegree Graduate 33,011 PointsHi Lucie
Task 3 asks you to create a variable named summary where you substitute the {} for your variable days. As stated above this is done using the format method of the string function. On another note you don't need to convert your values to integers as the compiler will pick this up automatically. So only convert datatypes when you have the following scenario. For example you would attempt to convert from a string to integer when you have something like this a=23 and b="25" and c= a * b which would throw an error as b is a string a not an integer. So the correct approach would be c = a * int(b).
age = 23
days = 23*52*7
summary = "I am {} days old!".format(days)
# you could convert days to a string if you wanted to but its not needed.
hope this helps a bit with datatypes as well.
akak
29,445 PointsThe answer is
summary = "I am {} days old!".format(days)
You can look up again this https://teamtreehouse.com/library/python-basics/ins-outs/string-formatting video for explanation how and why :)
Lucie Richard
1,172 PointsThank you ! I've tried so many possible answers but it wasn't the exactly one :) I've to work a lot ^^...