Can anyone simplify this for me?
I don't know if it is going to work I tried to adjust the code to fit on the page. Might have to delete the extra +\
def main():
try:
infile = open('text.txt','r')
files = infile.readlines()
lower,count,blank,dig = 0,0,0,0
#Counting uppercase
for line in files:
count+=line.count('A')+line.count('B')+line.count('C')+line.count('D')+\ +line.count('E')+line.count('F')+line.count('G')+line.count('H')+\
+line.count('I')+line.count('J')+line.count('K')+line.count('L')+\
+line.count('M')+line.count('N')+line.count('O')+line.count('P')+\
+line.count('Q')+line.count('R')+line.count('S')+line.count('T')+\
+line.count('U')+line.count('V')+line.count('W')+line.count('X')+\
+line.count('Y')+line.count('Z')
print 'There are',count,'uppercase letters.'
print
#Counting lowercase
for line in files:
lower+=line.count('a')+line.count('b')+line.count('c')+line.count('d')+\
+line.count('e')+line.count('f')+line.count('g')+line.count('h')+\
+line.count('i')+line.count('j')+line.count('k')+line.count('l')+\
+line.count('m')+line.count('n')+line.count('o')+line.count('p')+\
+line.count('q')+line.count('r')+line.count('s')+line.count('t')+\
+line.count('u')+line.count('v')+line.count('w')+line.count('x')+\
+line.count('y')+line.count('z')
print 'I also have',lower,'lowercase letters.'
print
#Number of didgits
for line in files:
dig+=line.count('0')+line.count('1')+line.count('2')+line.count('3')+\
+line.count('4')+line.count('5')+line.count('6')+line.count('7')+\
+line.count('8')+line.count('9')
print 'The number of digits in the file =',dig
print
#number of whitespace characters
for line in files:
blank+=line.count(' ')
print 'I found',blank,'whitespaces in this file'
print
raw_input('Hit enter to quit')
infile.close
except:
print 'An error occured.'
main()