-
-
Save AnisahTiaraPratiwi/f79debd0d84da325dd2473e0c3de3b6f to your computer and use it in GitHub Desktop.
# REPLACE THIS STARTER CODE WITH YOUR FUNCTION | |
def month_days(month,days): | |
print(month + " has " + str(days) + " days.") | |
month_days("June","30") | |
month_days("July","31") |
Nice. It will help me.
this code didn't work
`This answer is for this question type.
def month_days(month, days):
result = f"{month} has {days} days."
return (result)
print (month_days("June", 30))
print (month_days("July", 31))`
this code didn't work
This answer is for this question type.
def month_days(month, days):
result = f"{month} has {days} days."
return (result)
print (month_days("June", 30))
print (month_days("July", 31))
This is the correct answer:
def month_days(month,days):
m_days = days
print(month + " has " + str(m_days) + " days.")
month_days("june", 30)
month_days("july", 31)
Python
def month_days(month, days):
print(month, "has", days, "days.")
month_days("June","30")
month_days("July","31")
this code didn't work
To get it right, you should replace "+" with "," in the print line.
I don't get it
Arent we suppose to remove the instruction in line 1 a and replace it
def month_days(month,days):
print (month +" has "+ str(days) +" days.")
month_days("June",30)
month_days("July",31)
#TRICK is to add spaces, it is actually " has " not "has", so add spaces before and after writing "has" inside the apostrophes and also before "days." and it will work.
for more clarity:
correct one= " has " " days."
wrong one = "has" "days."
I hope it made sense :)
So I was wondering why my code wasn't accepted. Turns out you have to use their exact variable name. I was using "month_day", but the program was expecting "month_days" so it was not accepted.
Learned I need to carefully read the requirements and follow them. Hope that helps others who are wondering.
def month_days(months, days):
x=(f"{months} has {days} days")
return x
print(month_days("June", 30))
print(month_days("July", 31))
output:
June has 30 days
July has 31 days
Excellent!