Text analyzer


(command-line program)



wordseps=list("\|!%/()='?^[+*]°#§,;.:- ")
def wordcount(a):
    wc=0
    counter=False
    for i in a:
       if (not (i in wordseps)) and (counter==False):
           wc=wc+1
           counter=True
       elif (i in wordseps) and (counter==True):
           counter=False
    return wc
while True:
    print("Input a text line:")
    l=input()
    print("Your line was "+str(len(l))+" characters long")
    print("Your line was "+str(wordcount(l))+" words long")
    print("Press Enter to try again or input 'N' to exit:")
    n=input()
    if n=="N":
        break
	
	

Return