【发布时间】:2019-12-14 17:25:02
【问题描述】:
尽管我的解决方案是正确的,但当我尝试在hackerrank 上解决此问题时,我无法弄清楚为什么它会显示错误。我无法理解 STDIN 和 STDOUT。请参考我附上的图片:
import sys
def triangle(my_string = sys.stdin.readline()):
# first parse the standard input which is in form of string
char = []
for i in str(my_string):
char.append(i)
# is all the sides of the triangle are equal it is equilateral triangle
if char[0] == char[1] == char[2]:
print("Equilateral")
# if two sides are equal it is an Isosoleces triangle
elif (char[0] == char[1]) or (char[1] == char[2]) or (char[2] == char[0]):
print("Isosceles")
# if all three sides are different it is an Noneofthese
else:
print("None of these")
【问题讨论】:
-
你永远不会打电话给
triangle -
Please don't post screenshots of text。它们无法被搜索或复制,并且可用性差。相反,将代码作为文本直接粘贴到您的问题中。如果选择它并单击
{}按钮或Ctrl+K,则代码块将缩进四个空格,这将导致其呈现为代码。