#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)
-
Dear Student and Parent or Guardian, The Santa Clara County Superintendent of Schools and all county district superintendents have deci...
-
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...
-
1) Mr Burnham Saying Hi with some updates... Last Class Video This Week Monday PM Class Hangounts Party Call... Tuesday 8:30 AM Chat wi...
No comments:
Post a Comment