Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reverse a number
#1
Hi! So for my homework assignment, we have to reverse a four digit number.

# Python Class 2402
# Lesson 2 Problem 6
# Author: KitKatKarateIlluminati (491160)

FourDigit = int(input("Please enter a four digit number: "))

First = FourDigit % 10
Second = ((FourDigit % 100) - First)/10
Third = (FourDigit - (Second * 10 + First))/100
Fourth = (FourDigit - (First + Second * 10 + Third * 100))/1000

Reverse = Fourth + Third * 10 + Second * 100 + First * 1000
print(Reverse)
Can you guys please tell me why this is wrong?

Thanks in advance!
Big Grin
Reply


Messages In This Thread
Reverse a number - by kLgG40 - Apr-29-2020, 02:54 AM
RE: Reverse a number - by perfringo - Apr-29-2020, 04:57 AM
RE: Reverse a number - by anbu23 - Apr-29-2020, 06:23 AM
RE: Reverse a number - by DeaD_EyE - Apr-29-2020, 09:01 AM
RE: Reverse a number - by pyzyx3qwerty - Apr-29-2020, 09:51 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020