In [5]:
#defines a fuction called leave
def leave():
    #creates a variable called answer which value is set through the user 
    answer = input("would you like to go again? Y or N ==> ")
    #checks to see if answer is equal to Y/y and if it is then it runs its set function
    if answer == "Y" or answer == "y":
        #brings the user back to the main function
        main()
    #tells that if the if statement didn't occur then to check to see if answer is = N/n and to then run a function 
    elif answer == "N" or answer == "n":
        #tells you to have a good day
        print("have a good day")
    #if all others options were to not occur then this function will be used 
    else:
        #tells you that you must respond with the set answers
        print("You must respond with the set answers.")
        #runs the leave function again because of the error from before 
        leave()

#defines a function called main
def main():
    #it will try to run its set function to see if thier is any errors
    try:
        #makes a variable called terms which value depends on the users input
        terms = int(input("how long will you like the function to loop? ==> "))
        #makes a variable called firstFib which has a value of 0
        firstFib = 0
        #makes a variable called secondFib which has a value of 1
        secondFib = 1
        #makes a variable called counter which has a value of 0
        counter = 0
        #makes a list called fibList
        fibList = []
    
        #states that while the counter variable is less than the terms variable this function will run
        while counter < terms:
            #adds the firstFib variable to the list that will be printed at the end 
            fibList.append(firstFib)
            #adds the firstFib and the secondFib variable to make a new variable called thirdFib
            thirdFib = firstFib + secondFib
            #gives the value of the secondFib to the firstFib variable
            firstFib = secondFib 
            #gives the value of the thirdFib to the secondFib variable
            secondFib = thirdFib
            #adds 1 to the counter variable
            counter += 1
        #prints the fibList so we can display the work
        print(fibList)
        #brings up the leave function
        leave()
    #if a error occurs this function is run
    except:
        #tells the user to make sure they mark the value of terms as a positve whole number
        print("be sure the value of answered question is a positive whole number.")
        #goes back to run the main function again
        main()

#marks the end of the main function
main()
how long will you like the function to loop? ==> 10
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
would you like to go again? Y or N ==> n
have a good day
In [ ]: