#!/usr/bin/python
def main():
name = raw_input("Tell me your name please ")
num = int(input("Enter a number "))
print(name + " your number is " + str(num))
d1 = num // 100
num = num % 100
d2 = num // 10
d3 = num % 10
print("The number reversed is {}{}{}".format( d3, d2, d1, ))
main()
I was given the below code and told to fill in the blanks so that when a number is entered, it is outputted reversed. So if I put in 423 it would output 324. It also said if 9 was entered 009 should be outputted. Please help!
This is what was given:
def main ():
name = _______("Tell me your name please ")
num = int(input("Enter a number "))
print(name,"your number is", num)
d1 = num // _____
num = num _____100
d2 = __________
d3 = __________
print("The number reversed is ", d3, d2, d1, _______)
main()
This is what I have:
def main ():
name = input("Tell me your name please ")
num = int(input("Enter a number "))
print(name,"your number is", num)
d1 = num // 100
num = num / 100
d2 = int((((num-d1)*10))//1)
d3 = int(((((num-d1)*10)-d2)*10)+1)
print("The number reversed is ", d3, d2, d1, sep='')
main()