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 (Retired) Things That Count Things That Count

Python Basics, Things That Count, Challenge task 3 of 4

Hi all!

What am I doing wrong here? It always says that the value of "decades" is wrong. I tried to divide by 10 and by 10.0 but either way it doesn't work.

The funny thing is that I did this challenge a couple of weeks before and I solved it just fine. I have just started Python again from the beginning because I forgot the most of it :)

age = 31
days = age * 52 * 7
decades = age / 10.0

5 Answers

Try wrapping "float" method around "age/10". I'm sure it didn't need that last time I took the challenge too. But I can't be 100% positive. Has the challenge been updated Kenneth Love ?

Thanks!

Now it works just fine. I tried similar things before like wrapping the "float" method around "age" and "10" etc. but I did not wrap the whole statement.

This works:

age = 31
days = age * 52 * 7
decades = float(age/10)

Thank you!

Martin Luckett
Martin Luckett
32,591 Points

TTH have been having issue with the code challenges today.

I've just tried the challenge again and get the same result as you.

First with an integer "10" which results in a "...should be a float" error and then the same issue as you.

I think it is a Treehouse issue - your code seems fine.

Edit : Andrew's solution works with casting as a float but I'm fairly sure I didn't do that first time I did the challenge.

I think the challenges issue is sorted now http://status.teamtreehouse.com/ (fingers crossed)

Hi Martin,

I was also thinking that there is something wrong with the Workspace but everything is ok. Andrew solved it.

But thank you too!

As of right now, age / 10 still doesn't pass.

I'm pretty sure that has worked for others.

I think this course is using python 3.x?

According to the python docs, division of integers will result in a float. You would have to use floor division, //, to get an integer result.

The / (division) and // (floor division) operators yield the quotient of their arguments. The numeric arguments are first converted to a common type. Division of integers yields a float, while floor division of integers results in an integer; the result is that of mathematical division with the β€˜floor’ function applied to the result. Division by zero raises the ZeroDivisionError exception.

12 / 10 should yield 1.2 and 12 // 10 should yield 1

I don't think this is the case if the challenge is checking against a 2.x version of python.

I would say that the challenge still isn't working then if it's going by a 3.x version.

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Everything should be running Python 3.4, but I'll double-check with the devs to make sure.

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Just tested this CC again and it seems to be fixed. Your answer should get you to the next step.

Thank you.