Why I'm getting Error in my code? Help me out please! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why I'm getting Error in my code? Help me out please!

https://code.sololearn.com/cDU04hrZs33A/?ref=app

21st Oct 2018, 11:18 AM
Vinayak Thube
Vinayak Thube - avatar
7 Answers
+ 1
You should change the lines 3, 4, 5 and 6 to: num=int( input("insert number: ")) b=num%10 a=num-b And the last line to: print(a,b)
21st Oct 2018, 3:59 PM
NicolasHM
NicolasHM - avatar
+ 3
it's only hapen between 11 to 19 isnt it ? so here the a's value are still in integer, meanwhile b now change to string. thats why at you get an error at last statement a+b
21st Oct 2018, 12:07 PM
Taste
Taste - avatar
+ 1
thank you Taste and NicolasHM 🤙🏻🤙🏻
22nd Oct 2018, 1:20 AM
Vinayak Thube
Vinayak Thube - avatar
+ 1
Vinayak Thube, the % operator can pick only a part of a number. Then, i make a division by 10 and pick the rest, that results in exactly the second digit of the number inputed. Example: number=28 28%10 is the same of 28/10 = 2 => 2*10=20 => 28-20=8 and that is what the % do. After, i subtract the second digit of the number, what result in the ten part of the number. Ex: 28%10=8 28-8=20 I hope that you can understand.
22nd Oct 2018, 2:57 AM
NicolasHM
NicolasHM - avatar
+ 1
NicolasHM again thanks a lot for helping......I understand it🖐️🖐️
22nd Oct 2018, 3:22 PM
Vinayak Thube
Vinayak Thube - avatar
0
NicolasHM 🤙🏻🤙🏻That's great your answer code helped a lot......for making advance version of that🤘🏻Thanks a lot
22nd Oct 2018, 1:36 AM
Vinayak Thube
Vinayak Thube - avatar
0
NicolasHM Hey, can you explain me how your answer works? num=int( input("insert number: ")) b=num%10 a=num-b And the last line to: print(a,b) 🤔🤔🤔🤔🤔🤔🤔
22nd Oct 2018, 2:13 AM
Vinayak Thube
Vinayak Thube - avatar