no idea why my program is not reading the text file correctly am I doing something wrong,
here is what i have so far

import string

count = 0

infile = open("text.txt", "r")

uppercasecount, lowercasecount, digitcount = (0, 0, 0)

def main():

for character in infile.readlines():

    if character.isupper() == True:

        uppercasecount += 1

    if character.islower() == True:
        lowercasecount += 1

    if character.isdigit() == True:

        digitcount += 1

    print(uppercasecount, lowercasecount, digitcount)

print("Total count is %d Upper case, %d Lower case and %d Digit(s)" %(uppercasecount, lowercasecount, digitcount))

main()

no idea why my program is not reading the text file correctly

I have no idea what that means.

Print the entire string you are checking and it will show the problem with the upper/lower/digit statements. The upper and lower may work but the digit will not because the input can not be converted to an integer.

infile = open("text.txt", "r")
for character in infile.readlines():
    print repr(character)

    if character.isupper() == True:
         print "Upper"

    elif character.islower() == True:
       print "Lower"

    elif character.isdigit() == True:
       print "Digit"

    else:
        print "None of the above"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.