Challenge: Appending an Element to a List
Test yourself and implement what you have learned so far in this challenge.
We'll cover the following
Problem Statement
You are given a list of elements and you have to append an element to the list which is equivalent to the first element of the same list.
Input
The input is the List list
to which you need to append an element.
list
has already been declared for you.
Output
The output will be finalList
.
Sample Input
("a","b","c")
Sample Output
("a","b","c","a")
Test Yourself
Write your code in the given area. Try the exercise by yourself first, but if you get stuck, the solution has been provided. Good luck!
//Rewrite finalListval finalList = List(0,0,0,0)
Let’s go over the solution review in the next lesson.