Add elements from one list to another list

In this program, we will add elements from one list to another list and print It in descending order.

Steps to solve the program
  1. Take a list as input and create another empty list.
  2. Use for loop to iterate over all the elements of the list.
  3. During iteration add elements to the empty list.
  4. Print the list in descending order using sorted().
				
					l1 = [2,5,8,0,1,4]
l2 = []

for ele in l1:
    l2.append(ele)
    
sorted(l2,reverse = True)
				
			

Output :

				
					[8, 5, 4, 2, 1, 0]
				
			

sort a list using for loop

find the maximum number from the list

Leave a Comment