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) Logic in Python Try and Except

Damian McCarthy
Damian McCarthy
3,656 Points

Its bad how bad I am at this.

I cant figure out how to get this float to work, Ive tried to many things this one was my most recent attempt.

trial.py
def add(num1, num2):

   return float(int(num1)) + float(int(num2))

add(5,10)
Dane Parchment
Dane Parchment
Treehouse Moderator 11,075 Points

Don't say you are bad at this, it is normal to grasp these topics on your first try.

For you, I would recommend that you actually re-watch this section and possibly the previous one as well. It seems to me like you are moving a bit to fast through these lessons and aren't giving yourself time to properly understand them.

Patience and taking it slow are the most important traits to have while learning and while doing programming. If you need to watch a video 3 times to understand it, do so! But rushing through these videos and challenges won't help you if are not grasping the concepts being taught in them.

I am not saying that you are rushing through them, but from your previous question, it looks to me like you are not understanding this part of series. So probably re-watching the section will help!

1 Answer

Dane Parchment
MOD
Dane Parchment
Treehouse Moderator 11,075 Points

Why are you casting them to integers inside of the float casts? It never asked you to do so...

Just cast the two variable to floats, don't do any integer casting.

Damian McCarthy
Damian McCarthy
3,656 Points

when i was just doing the float it was giving me a error saying that i cant make strings float, so that's why i did that. but i don't understand how its a string. so im just so confused ive watch them way to many times, but there's nothing on this scenario.