Chrome Extension

Reverse a string or number in python

The code snippet example can be used to reverse a string or number in python.
#reverse a number
my_num = 12345
reversed_num = str(my_num)[::-1]
print(reversed_num)
# -> 54321

#reverse a string
my_str = "hello"
reversed_str = my_str[::-1]
print(reversed_str)
# -> olleh
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
Was this helpful?
0 Comments