#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)
-
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...
-
1) Mr Burnham Saying Hi with some updates... Last Class Video This Week Monday PM Class Hangounts Party Call... Monday 12:30 PM Chat with ...
-
Special Instructions: Be ready to walk over to the Auditorium at 7:40 Entry Ticket - Did You Get an Email From Cisco? Find it and Sign ...
No comments:
Post a Comment