Apr-30-2020, 09:41 AM
(Apr-30-2020, 08:56 AM)Prani05 Wrote: Write a program which traverses the current working directory recursively and displays those files ending with .py.
Hint : Use walk method of os package.
import os if _name_ == "_main_": for files in os.walk("."): if .py in files: print(files)I tried this but am getting error
os.walk()
returns output in 3-tuple and third element has files list. Use the third element in if statmentYou have to enclose string in quotes.
if '.py' in ...