+ 1
Can you explain the following code, it reverses a no but I don’t know how it works?
n=12345 rev=0 while(n>0): dig=n%10 rev=rev*10+dig n=n//10 print("Reverse of the number:",rev)
7 Respuestas
+ 9
it takes the left digit using reminder operator
then multiple it with 10 to add the next digit at the right
usually I understand codes by printing the changes
check this may help
https://code.sololearn.com/c6Tgr225h1Ea/?ref=app
+ 8
welcome
+ 2
thank you both of you for your support , I am new to coding , your help really counts
~ swim ~ thank you , I didn’t downvoted your answer intentionaly may be it was something in haste though I realised my mistake now . I would look forward for your help in future