9. Reverse a Number

Acceptance — 0 accepted 0 submissions

Easy
No topics listed
No companies listed
Write a Python program that asks the user to enter a number. Then reverse the digits of that number and print the result. For example, if the user enters 1234, the output should be 4321. If the user enters a negative number like -321, reverse only the digits and keep the negative sign, so the output should be -123. The program must take the number as input from the user.

Example 1

Input
1234
Output
4321

Explanation 1234 reversed is 4321

Example 2

Input
-321
Output
-123

Explanation -321 reversed is -123 and negative sign is kept

Example 3

Input
0
Output
0

Explanation 0 reversed is 0

Acceptance —
Accepted 0
Submissions 0
Auto-save
Saved Ln 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
4321
No results yet
Run your code to test it against the sample cases.
Problem List