Home Resetting ALL variables when running main() in a loop
Reply: 0

Resetting ALL variables when running main() in a loop

user829 Published in May 25, 2018, 7:12 am

I'm looking to run a program again when asking the user: "Do you want to run the program again". No going to exit, and yes looping around and running main again. However I've noticed that python keeps the old variable assignments stored. Is there a quick way to clear the memory so that when the program loops again stores new variables?

At the moment i've just got: Please close the program and reopen it! Want to make it more elegant:

Here's what i've got so far:

def main()
    print("Do you want to solve another problem?")
    answer = input()
    while answer not in["yes","no"]:
        answer = input()

    if answer == "yes":
        print("Please close the program and rerun it")
        #main() #<-this is not working as expected
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.370927 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO