while True:
print ("wanna exit? type a number that not between(1-11)range")
side1 = input("Type 1st side: ")
side2 = input("Type 2st side: ")
side3 = input("Type 3rd side: ")
a= [1,11]
if (side1 not in a) :
print("You exit,goodbye! ")
break
else:
a = int(side1)
b = int(side2)
c= int(side3)
perimeter = (a + b +c )
print ("The perimeter of triangle is :", perimeter )
我输入1到10之间的数字,但它一次又一次地输出“你退出......”
答案 0 :(得分:3)
input()
返回一个字符串,而a
只存储整数。其次,您需要创建一系列值,而不仅仅是[1, 11]
列表。
side1 = int(input("Type 1st side: "))
side2 = int(input("Type 2st side: "))
side3 = int(input("Type 3rd side: "))
a= range(1, 12)