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 trialrashell smith
15,405 PointsI honestly Have no Idea what I am doing Wrong.
I have been on this for 30 mins, I am probably missing something small if you can help that would be great.
def add(first, second):
try:
except ValueError:
return None
else:
first=float(first)
second=float(second)
return (first+second)
1 Answer
Michael Hulet
47,913 PointsPython understands what code goes in what block by how much you indent it. Right now, Python sees the start of a function, then a ton of unrelated code. All your code after your function definition needs to be indented a level to tell Python that it goes inside that function. Also, your ordering of everything is a little out of whack. You need to place things that could fail in the try
block, and what to do if it fails in the except
block. An else
isn't necessary here