Link to home
Start Free TrialLog in
Avatar of Miguel Hernandez
Miguel Hernandez

asked on

Printing the result of a function in Python 3.6

Hi, this is my code:

def how_many_days(month_number):
            days_in_month = [31,28,31,30,31,30,31,31,30,31,30,31]
            print(how_many_days[8])

When I try to run it, I get an error message: "function object is not subscriptable".

Thanks for your help!
ASKER CERTIFIED SOLUTION
Avatar of Flabio Gates
Flabio Gates

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Flabio Gates
Flabio Gates

Oh and note in particular how I've moved the print call outside of your function.
Leaving it within your function will result in recursion which is NOT what you want in this case.
Avatar of Miguel Hernandez

ASKER

Flabio:

Thank you for your help.  I am trying to learn Python via Udacity and sometimes get confused!. For example, I believed that I need to use [] in ther [] in "returning" to specify that the element is from a list.