Count and display the number of vowels, consonants, uppercase, lowercase characters in string.

string=input('enter a string ')
vowels=0
consonants=0
uppercase=0
lowercase=0
others=0
i=0
while(i<len(string)):
     if(string[i]=='a'or string[i]=='A' or string[i]=='e'or string[i]=='E' or string[i]=='i'or string[i]=='I' or string[i]=='o'or string[i]=='O' or string[i]=='u'or string[i]=='U'):
        vowels=vowels+1
 
     if(ord(string[i])>=65 and ord(string[i])<=90):
         uppercase=uppercase+1
    elif(ord(string[i])>=97 and ord(string[i])<=122):
       lowercase=lowercase+1
    else :
       others=others+1
     i=i+1
consonants=len(string)-(others+vowels)
 
print('consonants ',consonants)
print('vowels ',vowels)
print('uppercase ',uppercase)
print('lowercase',lowercase)
 
Explanation :- Vowels are letters a,e,i,o and u. In this program we have taken input string from user. Initialized all the variables for counting vowels, consonants, uppercase, lowercase and others or alphanumeric characters. We have entered while loop and in this loop we are checking condition for vowels.
 
If match then counter for vowels is increased, similarly condition check for uppercase and lowercase letters is happening. ASCII value for lowercase letters is between 97 to 122 and for uppercase letters is 65 to 90. We have used ord function to get the ASCII value of character in string if condition matches we increase counters for uppercase and lowercase respectively.
 
If character don't fall in above conditions then it's a alphanumeric character. We are taking it as others variable and increasing the counter. To find the number of consonants we are subtracting total length of string from others and vowels counters. This way we are finding consonants. 
 
In the end after loop terminates, we are printing each variable using print function.