Python 3.4.3
I am trying to create an interactive drawing program using Python and turtle. My program runs by first asking the user to specify the length of the sides of the shape. If the length is greater than zero, the program will begin to execute.
I would like the program to continue running and to continue asking the user for information, up until the point the user enters the length of the sides as less than or equal to zero, at which point the program will exit. I am therefore using a ‘while-loop’ to run the program and ask the user for specifics.
I want the user to be limited to requesting one of the following three shapes; octagon, heptagon or hexagon. If the user enters anything other than this, I want the program to ask the user to specify their choice of shape again.
Therefore, I have the following code:
import turtle
lineLength = float(input("What length line would you like? "))
while lineLength > 0 :
print("You have choosen to draw a shape, please enter specifics:")
penColor = input("Please choose a pen color: ")
shape = input("which shape would you like to draw? ")
while shape.lower() != "octagon".lower() or shape.lower() !=
"heptagon".lower() or shape.lower() != "hexagon".lower() :
print("You have to select a shape from the specified list.")
shape = input("What shape would you like to draw: ")
Output: The actual output is that the code will run the "You have to select a shape from the specified list. What shape would you like to draw: " indefinitely; regardless of the input from the user.
Expected Output: My aim, and what I am expecting, is for the inner while-loop to exit once the user has input either octagon, heptagon or hexagon. In fact, I do not understand why the inner while-loop should run at all if the user selects one of these three shapes as the condition for the while-loop has not been met.