0

I was trying to improve this little code by adding a tasks history option but I failed miserably. Whenever I run the code the tasks3 list resets. What can I do to save the recent tasks?

import random

N = int(input("Enter the number of tasks: "))
tasks = []
tasks3 = []
tasks2 = []
tasks1 = []
for i in range(N):
    tasks.append(input("Please enter task: "))
    print(i)
Wheel = random.randint(0, N-1)
print("\n", Wheel)
print("Your task now is " + tasks[Wheel])
print(tasks)
if tasks3 == [] :
    tasks3 = tasks
else:
    if tasks2 == [] :
        tasks2 = tasks
    else:
        if tasks1 == [] :
            tasks1 = tasks
        else:
            tasks3 = tasks2
            tasks2 = tasks1
            tasks1.clear()
print("Recent given tasks: ", "\n", tasks1, "\n", tasks2, "\n", tasks3)
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Duthé
  • 11

1 Answers1

0

You could use pickle files in order to save your variablen in the disk: How do I save and restore multiple variables in python?

Tlaloc-ES
  • 4,825
  • 7
  • 38
  • 84