209k views
20 votes
Consider the following code segment.

firstList + ["guitar", "drums", "bass"]
secondList + ["flute", "violin"]
thirdList = []
thirdList + firstList
firstList secondList
secondlist thirdList
What are the contents of secondList after the code segment is executed?
А
[]
00
["guitar", "drums", "bass"]
с
["flute", "violin"]
D
["flute", "violin", "guitar", "drums", "bass"]

1 Answer

5 votes

Answer:


secondList = [

Step-by-step explanation:

At the third line of the code segment:

An empty list thirdList is created

At the fourth line of the code segment:

The content of firstList is passed into thirdList

i.e.
thirdList = [

At the fifth line of the code segment:

The content of secondList is passed into firstList

i.e.
firstList =  [

At the fifth line of the code segment:

The content of thirdList is passed into secondList

i.e.
secondList = [

User Razvan Dumitru
by
3.8k points