-1
입력 한 모든 도형의 영역을 제공하는 파이썬 프로그램을 만들고 있는데 어떻게 프로그램을 작성하는지 알고 싶습니다. 어떤 모양으로 사용자에게 묻는 지로 돌아갑니다. 그것은 단지 반복하기 때문에 코드가 매우 긴이기 때문에 새로운 형태에 대한 ELIF 문 같은 문, 그것은을 단축 할 수있는 방법이 있다면 그것은 ELIF을 많이하지 그래서 그들은 또한 가능하면내 코드가 사용자에게 입력을 다시 요청하는 방법
import math
user_choice = input("Choose a shape")
if user_choice == "rectangle" or "square":
a = input("enter your length in centimeters here")
b = input("enter your width in centimeters here")
area = int(a) * int (b)
print(area, "cm²")
else
print"Sorry, you may have made a spelling error, or have chose a shape that we cannot calculate. Please try again"
#Code that returns to first question here?
을 원하는 진술.
감사
힌트 :'while' 루프. – tadman