227k views
3 votes
3) Prompt the user for a 3-digit number, and the output should be the magical #, which is formed with each digit shifted to the left by one place. For example, if the user enters 512, the outputshould be 125. this is in python

User Kraken
by
4.7k points

1 Answer

2 votes

num = int(input("Enter a 3-digit number: "))

first = num//100

second = (num - (first*100)) //10

third = (num - ((first * 100) + (second *10)))

new_num = second*100 + third*10 + first

print(new_num)

I hope this helps!

User Spasticninja
by
4.5k points