Q:

Reverse the tuple using python programming

belongs to collection: Python Tuple Exercises

0

Reverse the tuple

Given:

tuple1 = (10, 20, 30, 40, 50)

Expected output:

(50, 40, 30, 20, 10)

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Hint:

Use tuple slicing to reverse the given tuple. Note: the last element starts at -1.

Solution:

tuple1 = (10, 20, 30, 40, 50)
tuple1 = tuple1[::-1]
print(tuple1)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

The given tuple is a nested tuple. write a Python ... >>