Shapes and Sizes return issue

I’m working on 5.3 step 10. For some reason i keep getting return outside function. What causes it to be outside function. i try indenting pi an few other things with no luck. any tips will help.
Tia

It sounds like, whatever value is being entered as circumference, is resulting in an answer for diameter that is not defined by your function.

Curious-- did you define and of the inputs or return variables as integers, floats, or so forth?

1 Like

Its wanting me to make it were some one can input a number. When I try run it, it said return outside function before a value could be given.
Thanks for responding

Hmm. Not sure. I’d have to see more of your code.

Hi, Christopher. Without seeing your code, it sounds like your return statement is on an incorrect indentation level. For example, if I wanted to write a function that adds 2 to a number and returns the sum, my function definition might look like this:

def add2(num):
    sum = num + 2
    return sum

Instead, if I had the following:

def add2(num):
    sum = num + 2
return sum

I would get an error for using return outside of a function. In Python, you can only use the return keyword inside of a function definition.

Hope that helps!

2 Likes

Thank you, Ryan.

(For those who may not know, Ryan helps to run the joint and clearly is a top-level coder).

–Thomas

Hi, Ryan

edit: Per our posting guidelines, please do not post significant amounts of code outside of private messages. Thanks!

my error i get after inputting the circumference is

File “python”, line 6, in
File “python”, line 3, in calulate_diameter
TypeError: unsupported operand type(s) for /: ‘type’ and ‘float’

Thanks for any tips you can give

That error you’re describing means that your program is attempting to divide a type by a float, e.g. char / SOME_FLOAT_HERE

It sounds like whatever you’re passing in to your calculate_diameter function as the circumference is a data type instead of the actual value. Check your print statement, which is likely to be where that function call happens, to see if that’s what’s going on.

would that cause it be object no callable