Python program to reverse a tuple

In this post we will learn how to reverse a tuple taken by user as we know that tuples are immutable, So in this program first we will convert the tuple into list and than reverse the list after reversing the list we will again convert the list into tuple and print the tuple. t=eval(input("enter numbers separated by comma" ))
print("user entered =",t)
print("reversed tupple is",t) Output:
enter numbers separated by comma 5,4,3
user entered = (5, 4, 3)
reversed tupple is (3, 4, 5) Happy Coding! Follow us on Instagram @programmersdoor Join us on Telegram @programmersdoor Please write comments if you find any bug in above code/algorithm, or find other ways to solve the same problem. Follow Programmers Door for more. #blog #interview #placement #learn #computer #science

        Contact Us

  • LinkedIn
  • Facebook
  • Instagram

©2023 by Programmers Door