#program Homework 4 gaps #program to count gaps between words #One or more spaces is defined as a gap sentence = ("G", "o", "o", "d", " "," ","t", "o", " ", "g", "o") gapcount = 0 previousCharSpace = "FALSE" for i in range (len(sentence)): if sentence[i] == " ": if previousCharSpace == "FALSE": gapcount = gapcount + 1 previousCharSpace = "TRUE" else: previousCharSpace = "FALSE" print ("Sentence 1: number of gaps ", gapcount) #version 2 sentence2 = "I am late for class" gapcount = 0 previousCharSpace = "FALSE" for i in range (len(sentence2)): if sentence2[i] == " ": if previousCharSpace == "FALSE": gapcount = gapcount + 1 previousCharSpace = "TRUE" else: previousCharSpace = "FALSE" print ("Sentence 2: number of gaps ", gapcount)