简体   繁体   中英

What's wrong with this program? Why I getting runtime error in my following python code?

Recently, I started to solve a problem with UVA online judge. But after submitting this program it shows the following message: 'runtime error'.

v = int(input().split())
t = int(input().split())
d = v * (2*t)
if (v >= -100 and v <= 100) and (t >= 0 and t <= 200):
    print(str(d))

I tried this code too. But the result is same.

v = int(input())
t = int(input())
d = v * (2*t)
if (v >= -100 and v <= 100) and (t >= 0 and t <= 200):
    print(str(d))

Message:

UVa Online Judge 12:40 AM (33 minutes ago) to me

Hi,

This is an automated response from UVa Online Judge.

Your submission with number 24507447 for the problem 10071 - Back to High School Physics has received the verdict Runtime Error.

This means that the execution of your program didn't finish properly. Remember to always terminate your code with the exit code 0.

Best regards,

The UVa Online Judge team

I don't see why .split() is needed in this example. The program seems to work fine without it

v = int(input())
t = int(input())
d = v * (2*t)
if (v >= -100 and v <= 100) and (t >= 0 and t <= 200):
    print(str(d))

Edit: The final print statement can also just be print(d) , there is no reason to convert it to a string

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM