Challenge: Add Elements to the List
Can we write code that will add elements at the end of the list?
We'll cover the following
Problem statement
Given a list, l
, add elements at the end of the list in Powershell and Python.
Given data
A list, l
given below:
l=[1,3,5,7]
Expected output
Print modified list:
l=[1,3,5,7,9,11]
Coding exercise
This problem is designed to check your understanding, so you are encouraged to solve it on your own. If you get completely stuck, then refer to the next lesson that will explain the solution in detail.
Python
Hint: Use the
.append
function to add an element to the end of the list.
Get hands-on with 1400+ tech skills courses.