Reading data to the file

source=input("Enter the source file:")
f=open(source,"r")
upper=0
lower=0
number=0
lines=0
spl=0
char=0
while(True):
ch=f.read(1)
    if(ch==''):
        break
    char+=1
    if(ch=='\n'):
        lines+=1
elif(ch>='0' and ch<='9'):
        number+=1
elif(ch.isupper()):
        upper+=1
elif(ch.islower()):
        lower+=1
    else:
spl+=1
print("The number of characters:",char)
print('The number of uppercase letters:',upper)
print("The number of lowercase letters:",lower)
print("The number of lines:",lines)
print("The number of numeric characters:",number)
print("The number of special characters:",spl)

Popular posts from this blog

Update

Types of arguments in python

Select