List manipulation


# List manipulation

# Creating list

Nterms = int(input("Enter number of terms in List:"))
L = []

print("Enter", Nterms, "numbers : ")
for idx in range(0,Nterms, 1):
ele = int(input())
L.append(ele)
print("Original list : ", L)

# Appending elements to end of list
ele = int(input("Enter element : "))
L.append(ele)

print("Appended list : ", L)

L.reverse()
print("Reversed list : ", L)

ntimes = int(input("Enter number of times to display list elements : "))
print(L*ntimes)

L1 = [1,3,5]
L2 = [2,4,6]

NewList = L1+L2
print("list 1 : ", L1)
print("List 2 : ", L2)
print("Concatenated list : ", NewList)

print(type(L))
SortedList = sorted(NewList)
print("Sorted List : ", SortedList)

No comments:

Post a Comment

Don't be a silent reader...
Leave your comments...

Anu