Python 我正在解决一个关于黑客等级的问题,我不知道如何阅读标准输入,但我的解决办法是,在黑客等级中出现鞋钉错误该怎么办

Python 我正在解决一个关于黑客等级的问题,我不知道如何阅读标准输入,但我的解决办法是,在黑客等级中出现鞋钉错误该怎么办,python,stdin,Python,Stdin,虽然我的解决方案是wright,但我无法理解STDIN和STDOUT。请参考我随附的图片,我无法理解为什么在hackerrank上解决此问题时显示错误 import sys def triangle(my_string = sys.stdin.readline()): # first parse teh standard input wich is in form of string char = [] for i in str(my_string):

虽然我的解决方案是wright,但我无法理解STDIN和STDOUT。请参考我随附的图片,我无法理解为什么在hackerrank上解决此问题时显示错误

import sys

def triangle(my_string = sys.stdin.readline()):
    # first parse teh standard input wich 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 eqaulatral triangle
    if char[0] == char[1] == char[2]:
        print("Equilateral")

    # if two sides are eqaul it is an isoleces triangle 
    elif (char[0] == char[1]) or (char[1] == char[2]) or (char[2] == char[0]):
        print("Isosceles")

    # if all three sides are diffrent it is an  Noneofthese 
    else:
        print("None of these")`enter code here`

下面是有效的代码。您必须将输入转换为整数。 此外,您将忽略输入中的空格。希望能有帮助

import sys

my_string = input()
# first parse teh standard input wich is in form of string
splits = my_string.split(sep=' ')
value1 = int(splits[0])
value2 = int(splits[1])
value3 = int(splits[2])

# is all the sides of the triangle are equal it is eqaulatral triangle
if value1 == value2 == value3:
    print("Equilateral")

# if two sides are eqaul it is an isoleces triangle
elif (value1 == value2) or (value2 == value3) or (value3 == value1):
    print("Isosceles")

# if all three sides are diffrent it is an  Noneofthese
else:
    print("None of these")

您从未调用过
triangle
。它们不能被搜索或复制,可用性差。相反,将代码作为文本直接粘贴到问题中。如果选择它并单击
{}
按钮或Ctrl+K,代码块将缩进四个空格,这将使其呈现为代码。