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 trialPablo Vizcaino
1,018 PointsI can't figure out how to multiply int
The challenge is to create a variable for age and a second variable for days where it multiplies the age by 52 and by 7.
This is what I have-
age = int(27)
days: print(int('age')*int(52)*int(7))
age = int(27)
days:
print(int('age')*int(52)*int(7))
3 Answers
rayorke
27,709 PointsIn Python, you aren't required to declare the variable type, as it is not a statically typed language. Python will figure out that:
age = 25
Means that you want to assign the integer 25 to the variable age.
With that in mind, all the question is asking you is the following:
days = age * 52 * 7
I hope that helps clarify the way Python handles variables!
On a side-note, if you ever want to find out what type your variable is, try the following:
type(age)
Will return:
<type 'int'>
Perry Stripling
20,210 Points[age] field should not be in quotes. Also, Not familiar with colon (:) syntax after 'days', I would calc "days = int(age), etc'' then "print(days)".
Pablo Vizcaino
1,018 PointsThanks for your help, Perry!
Mustafa Bayramov
4,778 Pointsage is already int age = int(27) print(age*int(52)*int(7)) print(int(27)*int(52)*int(7)) print("{}".format(age*int(52)*int(7)))
Pablo Vizcaino
1,018 PointsMustafa, so would the string
print("{}".format(age*int(52)*int(7)))
be the best one?
Pablo Vizcaino
1,018 PointsPablo Vizcaino
1,018 PointsThis is awesome thank you! I think I was overcomplicating it unnecessarily.