File tree Expand file tree Collapse file tree 4 files changed +21
-26
lines changed
Logic Building/Write a program to reverse digits of a number Expand file tree Collapse file tree 4 files changed +21
-26
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,24 @@ def reverse_digits(n: int) -> int:
19
19
20
20
return reversed_number
21
21
22
+
23
+ def reverse_digits_2 (n : int ) -> int :
24
+ """
25
+ >>> reverse_digits_2(1234)
26
+ 4321
27
+ >>> reverse_digits_2(0)
28
+ 0
29
+ >>> reverse_digits_2(1000)
30
+ 1
31
+ >>> reverse_digits_2(987654321)
32
+ 123456789
33
+ """
34
+ s : str = str (n )
35
+ s_reversed : str = s [::- 1 ]
36
+ reversed_number = int (s_reversed )
37
+ return reversed_number
38
+
39
+
22
40
if __name__ == "__main__" :
23
41
from doctest import testmod
24
42
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- ## reverse_digits_of_number Method
1
+ ## reverse_digits_of_a_number Method
2
2
- Reversing Digit by Digit
3
3
- Using rescursion
4
4
- Using String
5
- - Using String and Slicing in Python
Original file line number Diff line number Diff line change @@ -18,3 +18,5 @@ def y(a):
18
18
n = [1 , 2 , 3 ]
19
19
m = [i for i in range (2 )]
20
20
y (l for l in range (0 ,20 ))
21
+
22
+ uu : dict [int , ] = dict ([1 ,2 ,3 ])
You can’t perform that action at this time.
0 commit comments