I want to search for second column in text file and dont want to print the line if it matches specific word:
Title = line.split(" ")
TitleCheck =["apple" , "banana" , "mango"]
if not Title[1].startsWith(for word in TitleCheck)
print Title[1]
but it is giving error
SyntaxError: invalid syntax
Yes. It is invalid syntax.
try:
if not Title[1].startswith(tuple(TitleCheck))
Check the spelling of startswith. camelCase is incorrect.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.