比较用户';在Python中输入一个列表
我如何检查列表中是否有未列出的内容? 这是我当前的代码:比较用户';在Python中输入一个列表,python,list,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
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")
(我试着用“不在”,但没用)我想你想要:
for line in open("drivers_details.txt"):
if reg not in line:
etc.
不能对列表中没有的内容运行循环。循环基本上会在列表中的每个值上运行,所以显然这个循环永远不会是真的。请参阅以获取解决方案。