[Python] Python KeyError: 'OUTPUT_PATH'

Discussão em 'Python' iniciado por Stack, Agosto 21, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to run the following python code for to exercise

    #!/bin/python3

    import os
    import sys

    #
    # Complete the maximumDraws function below.
    #
    def maximumDraws(n):
    return n+1

    if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    t = int(input())

    for t_itr in range(t):
    n = int(input())

    result = maximumDraws(n)

    fptr.write(str(result) + '\n')

    fptr.close()


    but i get this error message

    Traceback (most recent call last):
    File "maximumdraws.py", line 13, in <module>
    fptr = open(os.environ['OUTPUT_PATH'], 'w')
    File "/home/inindekikral/anaconda3/lib/python3.6/os.py", line 669, in __getitem__
    raise KeyError(key) from None
    KeyError: 'OUTPUT_PATH'


    My Operation System is Linux Mint 19 Cinnamon. What i have to do?

    Continue reading...

Compartilhe esta Página