0
#if the user enters 1, it means the square and 2 means the triangle
print("1) Square \n2) Triangle\n")
num1 = int(input("Enter a number: "))

while num1 == 1:
    length = int(input("Enter the length(cm): "))
    length = length * length
    print("The area of the square is:", length)
    
while num1 == 2:
    base = int(input("Enter the base(cm): "))
    height = int(input("Enter the height(cm): "))
    base = 0.5 * base * height
    print(base)

if the user enters 5 for example, how do i make the code repeat back to:

num1 = int(input("Enter a number: "))
Daraan
  • 1,797
  • 13
  • 24
Dom
  • 1
  • 1
  • 1
    Your two `while` statements should both be `if`. Then, that entire block of code should be inside a `while True:` loop. – Tim Roberts Oct 11 '22 at 19:59

0 Answers0