If I type int(6.5)
on the interpreter prompt, the output is 6.
If I type int(input())
, and give 6.5 as an input, then it gives an error:
ValueError: invalid literal for int() with base 10: '6.5'
What is happening here?
If I type int(6.5)
on the interpreter prompt, the output is 6.
If I type int(input())
, and give 6.5 as an input, then it gives an error:
ValueError: invalid literal for int() with base 10: '6.5'
What is happening here?
Input() function takes string as input. It is equivalent to doing int('6.5') which is different from int(6.5) -> Casting double/float to int.