[Python] Remember the previous input

Discussão em 'Python' iniciado por Stack, Fevereiro 19, 2025.

  1. Stack

    Stack Membro Participativo

    I want to make it such that my code remembers the previous list that I inputted after putting my second list. Inputs work but it only shows the recent input list after wanting to show the previous information list.

    def inputting():
    print("Enter your name")
    global name
    name = input()

    print("Enter your favorite subject")
    global subject
    subject = input()

    print("Enter your height")
    global height
    height = input()

    print("Enter your country")
    global country
    country = input()
    inputting()

    global information
    information = [name, subject, height, country]

    previous = information

    print("Here is your basic social information about yourself: {} \n".format(information))
    print("Do you wanna input new information? y/n")
    choice = input()

    if choice == "y":
    inputting()
    information[0:4] =[name, subject, height, country]
    print("Here is your basic social information about yourself: {} \n".format(information))
    print("Do you wanna see your previous information? y/n")
    AC = input()
    if AC == "y":
    print(previous)
    else:
    print("Thank you.")



    What I'm thinking right now is to create another list consisting of the same categories for the second input, but I feel it to be redundant. Is there a way such that you use one list only?

    Continue reading...

Compartilhe esta Página