Is there a way to print "no date" once?
I always print like this
no date
no date
24 - 8 - 1995
no date
no date
no date
no date
no date
03 - 12 - 2014
no date
....
i want print like this
24 - 08 - 1995
03 - 12 - 2014
no date
15 - 10 - 1995
no date
this is the code
import os
for dirname, dirnames, filenames in os.walk('D:/Workspace'):
for filename in filenames:
if filename.endswith('.c'):
for line in open(os.path.join(dirname, filename), "r").readlines():
if line.find('date') != -1:
print line
break
else:
print "no date"
thanks for helping