#!/usr/bin/python #if there are python files in the directory # print out a list of them along with word counts #else # Kindly explain there are no python files in this directory from commands import getoutput from os import system output = getoutput("ls | grep 'py$' ").split() if len(output) > 0: for filename in output: system("grep if " + filename) else: print "No python files found"