Q:

The given tuple is a nested tuple. write a Python program to print the value 20

0

Access value 20 from the tuple

The given tuple is a nested tuple. write a Python program to print the value 20.

Given:

tuple1 = ("Orange", [10, 20, 30], (5, 15, 25))

Expected output:

20

All Answers

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

Hint:

The given tuple is a nested tuple. Use indexing to locate the specified item.

Solution:

tuple1 = ("Orange", [10, 20, 30], (5, 15, 25))

# understand indexing
# tuple1[0] = 'Orange'
# tuple1[1] = [10, 20, 30]
# list1[1][1] = 20

print(tuple1[1][1])

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

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now