i have a list contains some values.I want to check if any of the element is presented in another list with if statement. I have done something like if condition with list comprehension this but not working as expected. my code is
fileop=["create","open","append","delete","move","copy"]
a=raw_input("enter a command\n")
tokens=a.split(" ")
def data(i):
return i
if [data(i) in tokens for i in fileop] in tokens:
print "file operations"
if "create" in tokens:
print "create"
elif "open" in tokens:
print "open"
elif "delete" in tokens:
print "delete"
If my input is like delete file.how to get the correct keyword.
Aucun commentaire:
Enregistrer un commentaire