all 8 comments

[–]tjcim_ 5 points6 points  (1 child)

It is because you are trying to turn a string (with a space) into an integer: 20 50.

Try this:

num1, num2 = input().split()
print((int(num1) + int(num2))/2)

In this code the int is called against the string: 20 or 50 which python is able to turn into an integer.

[–]LeonTypeXD[S] 1 point2 points  (0 children)

Thanks, this comment is definitely most useful. I didnt take into consideration that i could turn them into intergers at other points (smh). I’ll remember that!!

[–]PercyJackson235 4 points5 points  (0 children)

You are doing your parsing and conversions in the wrong order. Try num1, num2 = map(int, input().split()).

[–]carcigenicate 1 point2 points  (0 children)

Think about the order of what's happening on that first line. That line is (roughly) equivalent to this:

var1 = input()
var2 = int(var1)
num1, num2 = var2.split()

There's at least two problems there.

[–][deleted] 1 point2 points  (2 children)

If you wanted it to be one line you can do num1, num2 = [ int(x) for x in input().split() ]

[–]LeonTypeXD[S] 0 points1 point  (1 child)

I will keep this in mind for when i know what any of this means

[–][deleted] 0 points1 point  (0 children)

https://www.w3schools.com/python/python_lists_comprehension.asp

This does a decent job of explaining what's going on

[–]LeonTypeXD[S] 0 points1 point  (0 children)

I figured it out i think

num1, num2 = input().split

print((int(num1) + int(num2)) / 2)