code = raw_input("Enter Code: ')
for line in open('test.txt', 'r'):
if code in line:
print line
else:
print 'Not in file'
The test.txt file looks like this
A 1234567
AB 2345678
ABC 3456789
ABC1 4567890
When input is A The print line returns all lines with A instead of just the first line. Note: the test.txt file has approximately 2000 entry's. I just want to return the line with the numbers for what ever the user inputs for now