Answer to Question #256682 in Python for Raju

Question #256682

Accessing Nested Lists


Write a program to create a list with the values at the given Indexes.


Sample Input 1

3

1  2

0 3

0 1

Sample Output 1

['hockey','grapes','banana']


1
Expert's answer
2021-10-28T01:23:32-0400


SOLUTION CODE FOR THE ABOVE QUESTION


#let us declare a nested list and initialize it
nested_list = [['hockey','grapes','banana', 'orange'], [100, 500,800], "hello", 2.0, 5]

#lets start printing the value in index 3, the forst one which is given
print(nested_list[3])#output should be 2.0

#printing the value at 1 2 i.e [1][2]
print(nested_list[1][2])#output should be 800

#print the all values of index 0
print(nested_list[0])#output should be ['hockey','grapes','banana', 'orange']

#printing the value at 0 3 i.e [0][3]
print(nested_list[0][3])#output should be orange

#printing the value at 0 1 i.e [0][1]
print(nested_list[0][1])#output should be grapes



SAMPLE PROGRAM OUTPUT



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS