-3

how would I check if something is not in a list? this is my current code:

for line not in line: open("drivers_details.txt"):
               if reg not in line:
                  name=input("what is your name?\n")
                  address=input("what is your address\n")
                  print (reg,name,address,"%0.2f"%average_time,"MPH")

(I tried to use "not in" but it didn't work)

David Andrei Ned
  • 799
  • 1
  • 11
  • 28
  • You can't run a loop over something that is not in the list. A loop basically runs over every value within the list, so obviously this loop is never going to be true. See http://stackoverflow.com/questions/22833893/python-if-not-in-list for solution. – Munir Dec 10 '15 at 16:35

1 Answers1

0

I think you want:

for line in open("drivers_details.txt"):
    if reg not in line:
        etc.
Riccati
  • 461
  • 4
  • 13