0

The code in question:

...
def year_view(theyear):
    """Year view.
    Given a year, create the calendar for it and show options."""
    global cal
    global MONTHS

    cls()
    cal.pryear(theyear)
    print()
    print("<< [P]revious year           [G]o to year                 [N]ext year >>")
    print("Type month name (Jan - Dec) to go to month                    [Q]uit cal")
    choice = input("> ")

    # g = 1

    if choice == 'p':
        year_view(theyear-1)
    elif choice == 'g':
        year_to_jump = int(input("Enter year to jump to: "))
        year_view(year_to_jump)
    elif choice == 'n':
        year_view(theyear+1)
    elif choice in MONTHS:
        month_view(theyear, themonth)
    elif choice == 'q':
        quit()
    else:
        input("Invalid choice, press ENTER to continue")
        year_view(theyear)
...

When inputting any value for choice, the following error is shown:

Traceback (most recent call last):
  File "cal.py", line 135, in <module>
    year_view(2022)
  File "cal.py", line 44, in year_view
    choice = input("> ")
  File "<string>", line 1, in <module>
NameError: name 'g' is not defined

Since it was a NameError, I attempted assigning a value to g, but a similar error occurred.

Previously, it would execute the code under elif choice == 'g' without errors.

Looking for help...

Oliver
  • 94
  • 8

0 Answers0