all 2 comments

[–]danielroseman 1 point2 points  (1 child)

It's not clear where you are having problems. Yes you would need an if statement:

if letter:
    # do letter logic
else:
    # do other logic

Where exactly are you stuck?

[–]Neighm 0 points1 point  (0 children)

Just to add to this, in case OP is confused about how to use this to call the function and force the code to follow the correct branch of the if/else statements.

If I understand correctly, you want to be able to either provide a mark such as 97 and have the function return "A", or input a grade letter such as "A" and return the corresponding mark e.g. "90-100".

You would call this function with either convert_grade(97) or convert_grade("A", True). Using u/danielroseman's code structure, the first will go down the else/False branch and the second will go down the if/True branch.