Apr-09-2021, 06:47 PM
I managed get it working, but apparently not in a way that is recommended. I simply added "global q" to the function which meant I didn't need the "return q".
There are 8 functions altogether many of which needed to provide a variable for use in the final calculation. It works well but my next task is to work out how to do it without using "global". I've got a few niggles to iron out and a few tweaks here and there first though. Overall, it's been fun!
Thank you for you help
There are 8 functions altogether many of which needed to provide a variable for use in the final calculation. It works well but my next task is to work out how to do it without using "global". I've got a few niggles to iron out and a few tweaks here and there first though. Overall, it's been fun!
Thank you for you help
def selected_day(event): global q q = int(combo_day.get()) combo_day = Combobox(frame) combo_day['values'] = list (range(1,32)) combo_day.set("Choose a day") combo_day.grid(row=2, column=0) combo_day.bind("<<ComboboxSelected>>", selected_day)Final calculation
def result(): day_code={ 0:"Saturday", 1:"Sunday", 2:"Monday", 3:"Tuesday", 4:"Wednesday", 5:"Thursday", 6:"Friday"} if year_input == 1752 and m == 9 and q <3: day = day_code[(q + 13*(m+1)//5 + k + k//4 + 5 - j) %7] print_result = Label(frame, text=day).grid(row=4, column=0) else: day = day_code[(q + 13*(m+1)//5 + k + k//4 + j//4 - 2*j) %7] print_result = Label(frame, text=day).grid(row=4, column=0)