List Object has no Attribute Split

Pilvion

Basically what the title says: I am trying to create a program that detects Usernames and Passwords in a file. However, whenever I run it, it comes up with this error:

Traceback (most recent call last):
  File "C:/Users/tom11/Desktop/Data Login.py", line 33, in <module>
    content  = raw.split(",")
AttributeError: 'list' object has no attribute 'split'

Here is the code where it is going wrong:

UCheck = ""
PCheck = ""
Username = input("Username: ")
Attempts = 3
while UCheck != "Y":
    lines = True
    f = open('Data.txt', 'r+')
    while lines:
        raw = f.readlines()
        content  = raw.split(",")
        if len(raw) == 0:
            print("That Username does not exist!")
            Username = input("Username: ")
        elif Username == content[0]:
            UCheck == "Y"
            lines = False

This is what is inside of the .txt file:

TheCloudMiner,Password123
TestUser,TestPass
Testing,Tester
Username,Password

I have read through some of the other answers but they are no help to me. Any help would be much appreciated.

blue_note

readlines() returns a list of strings, not a string. You want to apply split() on each line separately, so you should iterate over it with something like

for line in open(...).readlines():
    username, password = line.split(",")
    # rest of your code

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

'list' object has no attribute 'split'

Attribute Error: 'list' object has no attribute 'split'

AttributeError: 'list' object has no attribute 'split' - Python

AttributeError: 'list' object has no attribute 'split' cannot figure out error

Don't understand cause of this AttributeError: 'list' object has no attribute 'split'

Keep getting the AttributeError: 'list' object has no attribute 'split' error

Python 3.7 AttributeError: 'list' object has no attribute 'split'

df with lists inside. AttributeError: 'list' object has no attribute 'split'

'float' object has no attribute 'split'

Dictionary object has no attribute split

AttributeError: object has no attribute 'split'

'list' object has no attribute

'int' object has no attribute 'split' , but it's an object

AttributeError: 'list' object has no attribute 'split' when i try to split a row from csv file

Error: 'list' object has no attribute 'split' when i try to split a row from csv file

Print left side of a split number. AttributeError: 'list' object has no attribute 'split'

'list' object has no attribute 'shape'

'list' object has no attribute 'click'

'list' object has no attribute 'filter'

'list' object has no attribute 'get'

Ansible, list object has no attribute

'list' object has no attribute 'foreach'

'list object' has no attribute 'name'

'list' object has no attribute 'map'

list' object has no attribute 'date'

List object has no attribute 'detectedLanguage'

'NoneType' object has no attribute '_jvm' pandas split

AttributeError: 'NoneType' object has no attribute 'split'

'tuple' object has no attribute 'split_contents'