How to add the second last digit of a number and print the result in Python?

How to add the second last digit of a number and print the result in Python3

How to solve this problem (Step to solve this problem):

Take the lists variable to save the number
Take the input of number by the user
Now append the number to lists
Now find the reminder
And the last task is to divide the number
Finally, we do the sum of the number with lists(the number that input by the user)

Solution :

lists=[]    # Take the lists to save the number
number = int(input("Enter two digit number"))   # Take the input of number by the user 

lists.append(number)    # Now append the number to lists

number = number%100     # Now find the reminder 
number = number//10     # And last task is to divide the number

print("The Result:",number+lists[0])       # Finally we do the sum of the number with lists(the number that inout by the user)


If you have a better solution than this then comment on it.

Next Post Previous Post
No Comment
Add Comment
comment url