lines = f.readlines()
will create a list of each line in the text file. Provided that each username is on a separate line. Otherwise, you don't want to read it line by line, but rather some other delimiter.
What you want to do is to check if the username input is in that list. So you'd want:
if username in lines:
The problem with that though is it needs to be an exact match. If there is an extra whitespace, it will fail. So what you could do is use the .strip()
to clear any whitespace.
There is also another huge issue with:
print = input("Please enter your password")
You are using the print function to store your input string. When you use input
it will print it. And then what you really want is to store that input as something...I called it password
import random
print ("Welcome to the Music Quiz!")
username = input("please enter your Username... ")
f = open("C:/username.txt","r")
# Creates a list. Each item in the list is a string of each line in your text files. It is stored in the variable lines
lines = f.readlines()
# the strings in your list (called lines), also contains escape charachters and whitespace. So this will create a new list, and for each string in the lines list will strip off white space before and after the string
users = [user.strip() for user in lines ]
# checks to see if the username input is also in the users list
if username in users:
password = input("Please enter your password: ")
else:
print("That is an incorrect username")