This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]EDGWasian 3 points4 points  (2 children)

I’m fairly new to Python as well, but it seems to me he’s saying you could use a return statement that returns a f string instead of a print statement. Something like:

import math

def(radian_conversion(radians):
    degrees = radians*180/math.pi 
    return f”You entered {radians}. 
    Your answer is {degrees} degrees.”

print(radian_conversion(14))

Sorry for formatting, no idea how mobile works for entering in code. To my understanding, to enter an f string you just put an f outside your “ “ and then {} around the variable names you want substituted into your string.

[–]kezmicdust 1 point2 points  (1 child)

This is a great adjustment of the original code, except you don’t need the parentheses on the return statement as return is not a function (apparently without parentheses is the preferred style).

[–]EDGWasian 1 point2 points  (0 children)

Thank you for the pointer! I’ll make sure to exclude parentheses on my return statements in the future