Struggling to read from a file using a for loop.

Discussion in 'Python' started by Spuddy, Oct 8, 2019.

  1. Spuddy

    Spuddy

    Joined:
    Oct 8, 2019
    Messages:
    1
    Likes Received:
    0
    Here is some of my code:

    username1 = input ("Please enter your username")

    file = open ("login.txt","r")
    for loop in range(2):
    line = file.readline()
    data = line.split (",")
    if data[1] == username1:
    print("Your username is correct, please enter your password")

    It doesn't do the if statement after i use the correct username which can be found in the file i have attached below.
    Any feedback would be greatly appreciated :)
    upload_2019-10-8_15-15-2.png
    -Aiden
     

    Attached Files:

    Spuddy, Oct 8, 2019
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.