My assignment is:
You have been asked to write a program that will give the name of a shape depending on the number of sides. The user can only enter numbers between 3 and 8, if they enter any other number then the program should tell them to enter a number between 3 and 8.
And here's my Python answer:
#Sides and shapes
sides = int(input("How many sides on the shape are there? "))
if sides ==3:
print ("Your shape is the triangle")
if sides ==4:
print ("Your shape is the square")
if sides ==5:
print ("Your shape is the pentagon")
if sides ==6:
print ("Your shape is the hexagon")
if sides ==7:
print ("Your shape is the heptagon")
if sides ==8:
print ("Your shape is the octagon")
elif sides != range(3,9):
print ("You should enter a number between 3 and 8")
After the elif
statement I somehow also need to loop it so that if the person inputs other than 3-8 then it will keep asking for them to enter a number from 3 to 8.
The elif
statement does not work for some reason and outputs this answer in F5:
How many sides on the shape are there? 6
Your shape is the hexagon
You should enter a number between 3 and 8