Click here to Skip to main content
15,039,037 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
#Create a function named daysInMonth that takes 1 argument.
#The argument would be a string that is the month, and the function should
#return an integer that is the number of days the month has in it.

What I have tried:

def daysInMonth(x):
month = "February"
return month

daysInMonth(28)

print(daysInMonth)


(im new btw dont hate)
Posted
Updated 15-Dec-20 22:17pm
Comments
Richard MacCutchan 16-Dec-20 5:02am
   
Read the question again carefully. What is the input parameter? What is the expected return value? Think about how you would do this if someone asked you, "how many days are there in July?".

You show no attempt to solve the problem yourself, you have no question, your main effort is pasting the requirement, you just want us to do your HomeWork.
HomeWork problems are simplified versions of the kind of problems you will have to solve in real life, their purpose is learning and practicing.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.
   
Read your homework assignment again:
Quote:
The argument would be a string that is the month
You are passing in an integer instead of a string.
Quote:
the function should return an integer that is the number of days the month has in it
You are returning a string.

You are also not doing anything with the parameter - the returned value needs to be different depending on the value of the parameter.

The Python Tutorial — Python 3.9.1 documentation[^]

It's not clear from the wording of your homework whether you are expected to take leap years into account, and if so, which year you are expected to use.
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900