0

I am fairly new to coding, and as such feel like I've been defaulting to creating large if, elif and else statements. Is there a better way to create the following function? Is there anything wrong with creating large functions like this?

def option_selector(option):
    if option == 'Long Call':
        return get_graph_value(long_call)
    elif option == 'Short Call':
        return get_graph_value(short_call)
    elif option == 'Long Put':
        return get_graph_value(long_put)
    elif option == 'Short Put':
        return get_graph_value(short_put)
    elif option == 'Straddle':
        return straddle()
    elif option == 'Bull Spread':
        return bull_spread()
    else: print('No Function')
PBERTONE
  • 33
  • 4
  • 1
    Does this answer your question? [Too many if statements](https://stackoverflow.com/questions/31748617/too-many-if-statements) – Erich Apr 19 '20 at 20:12
  • 2
    The duplicate is not even for python, I think the one I flagged fits way better. – Erich Apr 19 '20 at 20:13

0 Answers0