python - NameError: name 'yearout' is not defined -



python - NameError: name 'yearout' is not defined -

please tell me wrong, , other ways needs improving

def finalcalc(y, d, m): end = (y + d + m) % 7 homecoming end def monthlook(m): if m == 1: monthout = 6 elif m == 2: monthout = 2 elif m == 3: monthout = 2 elif m == 4: monthout = 5 elif m == 5: monthout = 0 elif m == 6: monthout = 3 elif m == 7: monthout = 5 elif m == 8: monthout = 1 elif m == 9: monthout = 4 elif m == 10: monthout = 6 elif m == 11: monthout = 2 elif m == 12: monthout = 4 print(finalcalc(yearout, dayout, monthout)) def daysimp(d): dayout = d % 7 monthlook(monthin) def yearc(y): y = y % 100 yearout = y + (y // 4) yearrem = y % 4 if yearrem >= 2: yearout += 1 yearout = yearout % 7 daysimp(dayin) dayin = int(input("what day in month?")) monthin = int(input("what month number? - eg. jan 1")) yearin = int(input("what year?")) yearc(yearin)

the error says: "nameerror: name 'yearout' not defined"- please give me solution , answers other problems find, , ways simplified and/or improved.

yearout name defined in function yearc only; when phone call finalcalc() name not visible , error.

you have same problem dayout , monthout.

you need decide values yearout, dayout , monthout should be before phone call finalcalc(). perhaps wanted set names result of other functions? functions need utilize return create values available caller.

for example, alter yearc function homecoming new yearout value:

def yearc(y): y = y % 100 yearout = y + (y // 4) yearrem = y % 4 if yearrem >= 2: yearout += 1 yearout = yearout % 7 homecoming yearout

then store result of function in new name:

yearout = yearc(yearin)

and same other names , functions.

you want read through python tutorial on functions again.

python

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -