#Zim
# this is my file read example
# xfile=open('mbox-short-short.txt')
#fname=input('enter a file name ')
fname="zimShort.txt"
try:
fhand=open(fname)
except:
print('bad dog... no file found')
quit()
# Challenge 1
print(fhand)
counterOfLine=0
counterOfChar=0
counterOfZim=0
counterOfStartsWithZim=0
realZimCount=0
for line in fhand:
# Challenge 2
counterOfLine=counterOfLine+1
# Challenge 3
counterOfChar=counterOfChar+len(line)
#Challenge 4.1
if 'Zim' in line:
counterOfZim=counterOfZim +1
#print(line)
#Challenge 4.2
if line.startswith('Zim:'):
counterOfStartsWithZim=counterOfStartsWithZim +1
line = line.rstrip()
#real Challenge 4.1
lineListZim=line.split()
print(lineListZim)
for realZim in lineListZim:
if 'Zim' in realZim:
realZimCount=realZimCount +1
print('line count =', counterOfLine)
print('char count =', counterOfChar)
print('Zim count =', counterOfZim, 'Wait, is that right?')
print('Zim: count =', counterOfStartsWithZim)
print('Real Zim: count =', realZimCount)
Subscribe to:
Post Comments (Atom)
-
Is it Summer Time? Then you are going to want to CLICK HERE ... This is where I'm going to post for Summer Activities, Lessons and Proje...
-
Hey All my Fine Mechatronics Students... I hope you are doing great... and hope that you are still learning... I want to keep sending out Bl...
-
Mechatronics Engineering Google Site Special Instructions: Entry Ticket - Thermodynamics Assignment - Duration: 15 Min Link: Pres...
No comments:
Post a Comment