def findLocation(yearList, locationList, year):
i = 0
year = 0
getYear = input("What is the year of the Olympics you are looking for? ")
while i < len(yearList) and year == 0:
if yearList[i] == year:
found = 1
else:
i = i + 1
if found == 1:
print("The location of the Olympics in the year", year, "you chose was in", locationList[i])
else:
print("There is no location for that year")
#Main Program
findLocation(yearList, locationList, year)
I always get this problem where it says 'year' is not defined but I thought i defined it in my findLocation function. I know I need to define year in my main program but I dont know how to because I thought I already called it in my function.

New Topic/Question
Reply



MultiQuote







|