import string
def main():
    print ("This program calculates the number of words in a sentence")
    sent = input("Enter a sentence: ")
    words = str.split(sent)
    print ("The total word count is:", len(words))
    print ("The total character count-withspace is:", len(sent))
    retry = input('''
Would you like to try again?''')
    if retry == ("Yes") or retry == ('yes') or retry == ('YES'):
        main()
main()

with this i get the word count and character count +1 after i hit enter, but what do i do so that the word count changes as i am typing, abit like the way it works on MS Word.

Recommended Answers

All 3 Replies

You do gui and put timer event to update word count.

You do gui and put timer event to update word count.

cud you the code for that...i am new to python...just my second week in the language...and my thrid week in programming :D thanks

I give you chance to do something you don't know rather than do something I learned allready. If you get stuck I may help. You may also use callback on change of text widgets contents instead of polling the change by timer. read my signature for crash course on forum rules and do study the code snippet archive.

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.