Home > front end >  I am getting an error of: not enough values to unpack (Expected 2, got 1) im following a tutorial bu
I am getting an error of: not enough values to unpack (Expected 2, got 1) im following a tutorial bu

Time:11-19

This is the code I have used from a tutorial

def view():
    with open('My coding stuff\\passwords.txt', 'r') as f:
        for line in f.readlines():
            data = line.rstrip()
            user, passw = data.split("|")
            print("User:",user, ", password:", passw)

I have no idea what is wrong with the code I was trying to make a password manager by following a tutorial and i am just confused

CodePudding user response:

Please save data in password.txt in below format

User|pwd

CodePudding user response:

The problem in your code that you are assigning one value in tuple user, passw instead of 2 values which is returned by data.split("|").

I think that the file you are reading doesn't contain data in the format user | pass (each record seperated by | ) so it gives you this exception Error. I suggest to check the format of data in your file then edit your code according to it.

  • Related