I want it to find the following file in mylist: "Microsoft Word 105Prt" (this file name could vary but will always have "Word" in it.
for myfile in filelist:
if myfile.contains("Word"):
print myfile
How can I modify this to work in python 2.7.5 since contains doesn't work.
You can substitute find for contains and just check for a return code of something other than -1.
for myfile in filelist:
if myfile.find("Word")!=-1:
print myfile
You can simply use the in
keyword, like so:
if 'Word' in myfile:
print myfile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With