A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Given is a nested tuple. Write a program to modify the first item (22) of a list inside a following tuple to 222
Q:

Given is a nested tuple. Write a program to modify the first item (22) of a list inside a following tuple to 222

0

Modify the tuple

Given is a nested tuple. Write a program to modify the first item (22) of a list inside a following tuple to 222

Given:

tuple1 = (11, [22, 33], 44, 55)

Expected output:

tuple1: (11, [222, 33], 44, 55)

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 and modify it using the assignment operator.

Solution:

tuple1 = (11, [22, 33], 44, 55)
tuple1[1][0] = 222
print(tuple1)

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