0
votes

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.

Nope, that's impossible. If your code really looks like what you show us, then what you describe cannot happen. - Tim Roberts
What is lines? The iteration variable is line (singular). - Barmar
I guess lines is a variable you used earlier when reading from users.txt. - Barmar
You should take out the spaces around | in string2. - Barmar
@Barmar nailed it. You have a typo. Your loop is for line but you have lines.split. You should move the string2 stuff out of the loop, since those are constants. - Tim Roberts