【发布时间】:2016-05-17 10:36:13
【问题描述】:
我在代码的最后一个 else 中得到一个错误,但我知道除此之外它可能还有其他问题。我会很感激我能得到的任何帮助。谢谢:)
carryon = True
while carryon == True:
side1 = int(input("Please enter the smallest side of the triangle."))
side2 = int(input("Please enter the second smallest side of the triangle."))
side3 = int(input("Please enter the hypotenuse of the triangle."))
if (side1 ** 2) + (side2 ** 2) == (side3 ** 2):
print "Your triangle is a triple!"
user = input("Would you like to continue? Type y to continue entering side lengths, type n to stop.")
user.lower()
if user == 'y':
continue
elif user == 'n':
carryon = False
else:
print "Please type either y or n!"
else:
print "Your triangle is not a triple!"
【问题讨论】:
-
您收到的错误信息是什么?
-
@Dave2e 它说最后 else 的语法无效。
标签: python-2.7