a list to a function and return it in the reverse order

A.Write a program to pass a list to a function and return it in the reverse order.

 

B.  Write the function Replicate_n_times(Lst,n) to replicate the elements of a list n times, i.e. to

replicate the elements of a list for a given number of times.

Example:

Lst = [1, 2, 3, 4]

Replicate_n_time(Lst,2)

Lst = [1,1,2,2,3,3,4,4]

C. Write a program to count the occurrences of each element within a list.

Example:

Lst = [1, 23, 0, 9, 0 ,23]

1 occurs 1 time 23 occurs 2 times

0 occurs 2 times

9 occurs 1 times

Leave a Reply

Your email address will not be published.