Question: Complete the code so that after it gets a value for number and n from the user, it prints out the nth digit (from the

Complete the code so that after it gets a value for "number" and "n" from the user, it prints out the nth digit (from the right) of the given number.

Again, your solution should use mod (%) and integer division (//) to figure out this nth digit of the integer. Think about how you can do so.

As an example, if I have number = 123456, I want to be able to use mod and division in some way to fetch the 1st digit of this number (which is 6), or 2nd (which is 5), or 3rd (which is 4), etc. using some equation that involves the values of "number" and "n".

while True:

number = int(input("Please give an integer number: "))

n = int(input("Which position's digit do you want? "))

print( )

What should I put in inside print bracket using // and % ?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!