Ask Question

Assume the list numbers1 has 100 elements, and numbers2 is an empty list. Write code that copies the values in numbers1 to numbers2.

+1
Answers (1)
  1. 24 April, 12:40
    0
    numbers1 = [5]*100

    numbers2 = numbers1[:]

    print (numbers2)

    Explanation:

    We have used the Python programming language to solve this problem. First we created a list to have 100 elements line 1, numbers1 = [5]*100, This statement creates a list that has 100 elements (the integer 5). In line two, we assign the elements in the the first list to the second list numbers2, notice the full colon in the statement numbers2 = numbers1[:], This allows the elements of the first list to be copied into the second list and on line 3, we printout the the second list.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Assume the list numbers1 has 100 elements, and numbers2 is an empty list. Write code that copies the values in numbers1 to numbers2. ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers