Python Forum

Full Version: ValueError: invalid literal for int() with base 10: '2 5'
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In hackerrank, i got a question named average function.
i gave my code like this
def avg(nums):
    mean = (a + b) / 2
    return format(mean, '.2f')
print(avg(int(input())))
it is showing error like this
Error:
ValueError: invalid literal for int() with base 10: '2 5'
'2 5' is not a valid input that can be turned into an int, you would need to split the string and then turn the split items into int
How did OP manage to post here?
Quote:Any user with 50+ posts in the user group "Privileged User" or higher may read/write to this forum. This forum is invisible to everyone else.
(Jun-13-2020, 09:25 AM)pyzyx3qwerty Wrote: [ -> ]How did OP manage to post here?

I moved the thread to the wrong homework section, fixed it now. thanks.