I have to take numbers from a text file, put them in a list, and ask the user for a number and tell them whether it's in the list or not.
this is what I have:
#read numbers to list
infile = open('charge_accounts.txt','r')
lines = infile.read().strip()
list1 = [lines]
infile.close()
#ask user for #
inp = str(input('Enter an account number: '))
#determine if input is in list
#display invalid/valid
if inp in list1:
print('valid number')
else:
while inp not in list1:
print('invalid entry')
inp = input('try another number: ')
if inp in list1:
print('valid number')
break
The problem is it thinks all inputs are invalid. I assume I either messed up converting the file to a list or with the while loop but I don't know what to fix.