HW #5 part 2.py - #Purpose To get information on the string...

This preview shows page 1 out of 1 page.

#Purpose: To get information on the string entered by the user #Assumption: It will count specific tokens, charhcters, and sentences #inputs: int, string #Post-condition: it will print out all the collected infromation on the string def strings(str1): token = 0 tot = len(str1) word = str1.count(" ") sent = str1.count(".") for i in str1: if i == " ": token = token + 1 print("There is", len(str1),"charechters") print("There is", token, "tokens") print("There is", sent, "sentances") avraget = tot - str1.count(".") - str1.count(" ") / token print("The avrage token is", avraget) avgsent = sent / tot print("The avrage sentence is", avgsent) #Purpose: it will put the string on a loop to keep asking untill the user is done #Assumption: once the user enters "/done" the program will stop running

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture