grumpytitan's blog

By grumpytitan, history, 6 years ago, In English

Hi, im newbie here. i trying to learn how to use this site.

why is this code return run time error?

w = int(input()) h = int(input())

area = w*h print(area//2)

Test: #1, time: 278 ms., memory: 16 KB, exit code: 1, checker exit code: 0, verdict: RUNTIME_ERROR Input 2 4 Checker Log Exit code is 1

Also what does run time error mean?

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Runtime error means your code crashed. This is because input() reads in an entire line in python, so your code is trying to cast a string with two separate numbers in it into one number. It cannot do this, so your code crashes.

You can do something like w, h = map(int, input().split()), which will take in the two numbers and cast both to integers. In general, when testing programs you should use the copy button on the side of the sample, so that you can be sure you're following the input format.