am trying to create a python code that counts words,vowels,consonats,upperand lower case letter,and the frequency which has the option like Do you want to enter the text via the keyboard? Do you want to read in the text from a file?
here is how i got but idont if am heading the right way.
sentence = input("Enter a sentence: ")
import os, sys
def fileCount(filename):
if isinstance(filename, basestring) and os.path.isfile(filename):
txt = open(filename).read
linecount = txt.count('\n')
(filename,linecount,len(txt.split()),len(txt))
numUpperCase = 0
numVowel = 0
numChars = 0
sentence = ""
for character in sentence
if(character == ' '):
continue
if((character >= 'A') and (character <= 'Z')):
numUpperCase += 1
if((character =='a'),(character == 'A'),(character == 'e'),
(character == 'E'),(character == 'i'),(character == 'I'),
(character == 'o'),(character == 'O'),(character == 'u'),
(character == 'U'),(character == 'y'),(character == 'Y')):
numVowel += 1
numChars += 1
print("\nTotal number of UPPERCASE letters: \t%d" %(numUpperCase))
print("Total number of vowels: \t\t%d" %(numVowel))
print("Total number of characters: \t\t%d" %(numChars))