[Tutor] Principles of code reuse error (Nagaraj S)
Nagaraj S
archinagaraj at gmail.com
Fri Nov 19 16:51:54 EST 2021
HI
Can you please help me with this?
Below is the question, answer and the result error I received.
In this code, identify the repeated pattern and replace it with a function
called month_days, that receives the name of the *month *and the number of
*days* in that month as parameters. Adapt the rest of the code so that the
result is the same. Confirm your results by making a function call with the
correct parameters for both months listed.
def month_days(month, days):
print(month +" has " + days +" days")
month_days("june", "30")
month_days("july", "31")
Here is your output:
june has 30 days
july has 31 days
Not quite. Let your function do most of the work and just
pass the name of the month and the associated days as
parameters.
More information about the Tutor
mailing list