def gcd(num1, num2): '''returns the GCD of num1 and num2''' x = max(num1, num2) # larger y = min(num1, num2) # smaller r = x % y while r != 0: x = y y = r r = x % y return y ###### One-and-a-half Loop Version ###### num1 = input("Input a number: ") num2 = input("Input another number: ") while num1 != 'quit' and num2 != 'quit': result = gcd(int(num1), int(num2)) print("GCD is " + str(result)) num1 = input("Input a number: ") num2 = input("Input another number: ") print("Bye!") ##### Alternate Boolean Flag Version ####### finished = False while not finished: num1 = input("Input a number: ") num2 = input("Input another number: ") if num1 == "quit" or num2 == "quit": finished = True else: result = gcd(int(num1), int(num2)) print("GCD is " + str(result)) print("Bye!") def read_words(): '''prompt the user for a list of words (one at a time), then return the list''' word_list = [] next_word = input("Word: ") while next_word != '': word_list.append(next_word) next_word = input("Word: ") return word_list