Error in running program

Hey guys, hope your doing well.
This is my code for the triangle assignment, but I get the following error.
i’d like to know your thoughts on this.

# implement a main func
def main():
# ask user for the length of each side
    a_side = input("Enter the length of a side: ")
    b_side = input("Enter the length of b side: ")
    c_side = input("Enter the length of c side: ")

# save the returned results
    res = triangle(a_side,b_side,c_side)
    print(res)
# implement a func with three parameters
def triangle(a, b, c):
# check the conditions
    if a == b == c :
        return "equilaterl"
    elif a == b or a == c or b == c:
        return "isosceles"
    else:
        return "scalene"
# return their answers

# call the main func

main()

Here is the error:

"OSError: pytest: reading from stdin while output is captured! Consider using -s. "

You’re not supposed to have a main() or read any input from STDIN. The website expects you to write a single function that takes three arguments. If you try to read from STDIN, the tests will choke.

1 Like

Have a careful read of Testing on the Python track.

1 Like

Our Python online test runner uses Pytest at its core, and it is set to capture print() output. As the error states, you cannot use input() in your code when running Pytest with print() output captured.

Using input() in your code is a really bad idea in most cases - especially if you don’t sanitize your inputs or otherwise wrap it for error trapping.

And as Isaac has stated, we do not want programmers on the track to define a main() function - at best it complicates testing and at worst it might be ignored by the online test runner altogether.

Finally, as Glenn has pointed out, the track testing docs and the Pytest documentation are worth a careful read if you are testing locally. Testing while using input() is pretty complicated, and even using the -s option doesn’t work all of the time.