Feb-26-2021, 05:29 PM
I'm a lot older than 48 and I am doing homework right now. I figure I'll stop doing homework a few minutes before I stop breathing.
Your "effort" crashes because flag is only defined when the age entered < 0.
I would replace this:
You can also simplify the comparisons and your math:
Your "effort" crashes because flag is only defined when the age entered < 0.
I would replace this:
if dog_age < 0 : flag = Truewith
if dog_age < 0: raise ValueErrorYou already have an exception handler, you may as well use it.
You can also simplify the comparisons and your math:
if dog_age < 0 : raise ValueError elif dog_age <= 1 : dog_age_in_Human_years = dog_age * 15.0 elif dog_age <= 2 : dog_age_in_Human_years = dog_age * 12.0