Simple calculation | Sololearn: Learn to code for FREE!


Simple calculation

Hi! I want a result like below. Input the first number 7 Input the second number 8 7+8 = 15 And what I did was below print(‘Input the first number’) s=input() print(‘Input the second number’) t=input() c=int(s) + int(t) print(s ‘+’ t ‘=‘ c) What was wrong? Please help Also, if there is other way I can code (especially the last line) please advise

12/8/2018 4:11:10 PM

Lucy Lee

8 Answers

New Answer


You can't add int to str in Python and you can also write print(s, '+', t, '=', c)


Last line is wrong. You can use f string in last line. print(f'{s}+{t}={c}')


This also work. print(s+'+'+t+'='+str(c)) But this is so complex and mysterious.


Thx! but is there any other way to code it? I’m not at that stage yet haha


So ‘c’ should be string.... Why can’t I just print c without str?


Because it works when I print just ‘print(c)’. I don’t know the difference...


This helps a lot! Thank you!


thank you !