130k views
4 votes
Write a program that uses an initializer list to store the following set of numbers in a list named nums. Then, print the first and last element of the list.

56 25 -28 -5 11 -6

Sample Run
56
-6

please help urgent

1 Answer

4 votes

Answer:

my_list = list([56, 25, -28, -5, 11, -6])

print(my_list[0])

print(my_list[-1])

Step-by-step explanation:

python lists start at index 0.

if you want the first element, listname[0];

the second element listname[1];

and if you put a minus, it reads the list from finish to start.

last element is [-1], second to last element is [-2] and so on.

User Benjamin T
by
7.7k points