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 (2015) Python Data Types Age Calculation

whats the error here years = 35 days = years*365 float weeks = days/7

whats the error here


1 Answer

The problem is nothing but just that you have provided type of variable before assigning it a value.

It doesn't happens that way in Python.

Python is dynamic typed, where you dont have to specify the type of variable. Just assign it a value and it'll figure out what kind of variable it is by looking into the value assigned.

years = 35 
days = years*365 
#this seems like a c/c++ code.
#float weeks = days/7
#Unlike C/C++ python is not static-typed language.
weeks = days/7

For better readability, enclose your code inside three backtics. See Markdown Cheatsheet for more details.