Skip to content
← Back to Community
PYTHON PROGRAM FOR ADDING TWO NUMBERS
Profile icon
fawaz123

simple example for python language; used for adding two numbers by the user

Voters
Profile icon
may22ch21b054
Profile icon
fawaz123
Comments
hotnewtop
Profile icon
[deleted]

Traceback (most recent call last):
File "main.py", line 2, in
a=int(input("input a : "))
ValueError: invalid literal for int() with base 10: 'uwu'

Profile icon
fawaz123

yes of course bcz i dealt with integers only
thank you for attention @TaylorLiang

Profile icon
EllaFan

You could probably solve that error by using floats instead of integers.
This would read something like:
a=float(input("input a : "))
@fawaz123

Profile icon
fawaz123

can you check now ?? @EllaFan

Profile icon
EllaFan

Yeah, it works for integers & non-integer values. The only annoying would be that if the product is an integer, it appears with a ".0" tacked on to the end. @fawaz123

Profile icon
AllAwesome497

Could also use:

a=input("Number 1:\n>") b=input("Number 2:\n>") print("Sum:", int(a)+int(b))