将用户的输入与Python中的列表进行比较

时间:2015-12-10 16:14:12

标签: python list

我如何检查列表中是否有某些内容? 这是我目前的代码:

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")

(我尝试使用"不在"但它没有工作)

1 个答案:

答案 0 :(得分:0)

我想你想要:

for line in open("drivers_details.txt"):
    if reg not in line:
        etc.