First: Kattis specifies this error here:
Compile Error means that we failed to compile your source code. In order to help you debug the error, the compiler output is available as extra information. Information about what compilers and flags are used can be found on the help pages for each language.
And on the help page:
Now that we have determined a suitable type, we just have to read the data. Reading is done from standard input. In this problem, we should read until the end of the file (in other problems, there might be an integer at the beginning of the input, specifying how much to read, or there might be a special indicator denoting that there is nothing more to read). Using sys.stdin, this can be done as below:
I edited the sample from the site to fit your script:
# decision() method stays unchanged
for i in sys.stdin:
values = i.split()
a = int(values[0])
b = int(values[1])
decision(a,b)
So this is how you have tho change your loop.
Second: running your code on my machine (windows 10 / python3) does not return an error ecept if the input values given to the script are not as expected. But if you e.g. input a single digit for the second promt you get IndexError: list index out of range
because you cant split a string with a single character...
So aside from Kattis (which I do not know or use) I recommend implementing some kind of input validation for the start()
mehtod:
def decision(sweetJars, sourJars):
if sweetJars == sourJars == 0:
return
if sweetJars + sourJars == 13:
print("Never speak again.")
elif sweetJars > sourJars:
print("To the convention.")
elif sourJars > sweetJars:
print("Left beehind.")
else:
print("Undecided.")
def start():
inp = input('Enter number of tries:')
# this try block validates the input can be cast as int
try:
rounds = int(inp)
except ValueError:
if inp.lower() == 'q':
print('Script stopped!')
return
print('Please input a positive integer or "q" to quit!\n')
start()
else:
# also check if the number is positive (optional)
if rounds <= 0:
print('Please input a positive integer or "q" to quit!\n')
start()
else:
i = 0
# while loop, so loop iterations can be repeated until input is correct
while i < rounds:
inp = input('Enter two Numbers seperated by space:')
values = inp.split()
# validate if the sting was split (by checking the second element first) and both parts are int
try:
b = int(values[1])
a = int(values[0])
except ValueError:
print('Both values have to be integers\n')
except IndexError:
if inp.lower() == 'q':
print('Script stopped!')
return
print('Please input the values in the format: "X X"\n')
# only increment i if input was correct
else:
decision(a, b)
i += 1
print(f'\nTry {i} of {rounds}.\nTo quit early enter "q"')
if __name__ == '__main__':
start()
But this is propably overkill for the Kattis problem...
Run-Time Error
. Thats the problem theres no feedback on what the issue is__promt argument of
input`