here is my code:
tasks_file = open("tasks.txt", "r+")
for line in tasks_file:
string2 = "Task | Assigned to | Date assigned | Due date | Task complete | Task description"
keys = string2.split("|")
values = lines.split(",")
#declaring a dictionary
dictionary = dict(zip(keys,values))
print(dictionary)
tasks_file.close()
The code is importing from a different text file(I'm working with two text files; users.txt and tasks.txt), so on this part I'm importing from the tasks.txt file but when I run the code it shows info from the users.txt instead.
lines? The iteration variable isline(singular). - Barmarlinesis a variable you used earlier when reading fromusers.txt. - Barmar|instring2. - Barmarfor linebut you havelines.split. You should move thestring2stuff out of the loop, since those are constants. - Tim Roberts