reverse argument python code example

Example 1: reverse intergers in python

# Get the number from user manually 
num = int(input("Enter your favourite number: "))
 
# Initiate value to null
test_num = 0
 
# Check using while loop
 
while(num>0):
  #Logic
  remainder = num % 10
  test_num = (test_num * 10) + remainder
  num = num//10
 
# Display the result
print("The reverse number is : {}".format(test_num))

Example 2: reverse function python

# The Reverse operation - Python 3:
Some_List = [1, 2, 3, 4, 1, 2, 6]  
Some_List.reverse()  
print(Some_List)
# Result: [6, 2, 1, 4, 3, 2, 1]