I am trying to get a round value after division between two values.For example, for inputs dividend=10 and divisor =3 , my expected output is 3 but it's saying 3.0 and for inputs p = 7 and t = -3 it's expected out -2 but it's showing -3.0. When I try to run this code in Pycharm I get intended results but when I run this in Leetcode compiler I get following error. Can I optimise this solution? Below is my code
import sys
class Solution(object):
def divide_integer(self,dividend,divisor):
res = dividend/divisor
return round(res)
if __name__ == "__main__":
p=7
t=-3
dividend =10
divisor =3
print(sys.version)
print(Solution().divide_integer(p,t))
print(Solution().divide_integer(dividend,divisor))
I have changed my leetcode Python version to Python 3 just like it is in my Pycharm and now these inputs get passed but it's failing For inputs dividend = -2147483648 and divisor = -1 in leetcode when I click on submit.I am adding screenshot below