Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(PYTHON 3.8) Let's assume I have a list, in which I have two items, both of which are list themselves(without knowing how many integers in

(PYTHON 3.8)

Let's assume I have a list, in which I have two items, both of which are list themselves(without knowing how many integers in each list, but they are the same length).

For example:

main_list = [[1,2,3],[4,5,6]]

main_list[0] = [1,2,3]

main_list[1] = [4,5,6]

how can I perform operations (take addition for example) on the inner lists to their matching indexes by altering the inner lists but not removing them from main_list(temporary variables are fine)

(main_list[0])[0] += (main_list[1])[0]

(main_list[0])[1] += (main_list[1])[1]

(main_list[0])[2] += (main_list[1])[2]

...and so on, using a loop, I can't hardcode it as i don't know the length of the lists(though I do know they are the same length)

to make main_list[0] = [5,7,9]

and main_list[1] stays the same

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

what is an Entety Relationship Diagram in the database

Answered: 1 week ago