# File: guessPolish.py # Author: Dr. Gibson # Date: 2/15/2018 # Section: N/A # E-mail: k.gibson@umbc.edu # Description: # This file contains python code that asks the user to guess # the number of nail polish bottles owned by Dr. Gibson. # UPDATED to make it a guessing game by using a while loop. def main(): numBottles = 297 # if a string for an input is particularly long, or if you want to # use it again, you can assign it to a variable and print that out message = "How many bottles of nail polish does Dr. Gibson own? " guessBottles = int(input(message)) # have the user keep guessing while they HAVEN'T # guessed the right number of bottles yet while guessBottles != numBottles: if guessBottles < numBottles: print("That's too low. Guess higher!") else: print("That's too high. Guess lower!") # ask for another guess, using the message variable from before guessBottles = int(input(message)) # at this point, we've exited the while loop # (notice the indentation of this line) print("Yup! Dr. Gibson owns", guessBottles, "bottles of polish.") main()