def cal(a,b):
print(a,'+',b,'=',a+b)
print(a,'-',b,'=',a-b)
print(a,'*',b,'=',a*b)
print(a,'/',b,'=',a/b)
n=int (input ('two integer inputs:')).spilt()
cal(n)
If you create a function like this and enter two integers, the error 'invalid literal for int() with base 10:' appears. Why is there such an error even though I entered an integer?
python error split
It's because I split the int.
def cal(a,b):
print(a,'+',b,'=',a+b)
print(a,'-',b,'=',a-b)
print(a,'*',b,'=',a*b)
print(a,'/',b,'=',a/b)
n=list (map(int, input('Enter two integers:')).split()))
cal(n[0], n[1])
© 2024 OneMinuteCode. All rights reserved.