Problem Description
Write a Program to create a list and get the input from the user.
Hint:
1. Get the size of the first list from the user
2. Get the size of the second list from the user
3. Get the elements of the first list
4. Get the elements of the second list
5. Get the element to be deleted in the list from the user
Operations:
1. Concat both the lists and display the combined or extended list
2. Display the list in the reverse order
3. Delete the element entered by the user (Hint step 5)
4. Display the final list after deletion of the elementCODING ARENA
a=int(input())
b=int(input())
x=[]
y=[]
for i in range(a):
n=int(input())
x.append(n)
for i in range(b):
n=int(input())
y.append(n)
print("The Extended List")
x.extend(y)
print(x)
print("The Reverse List")
x.reverse()
print(x)
k=int(input())
x.remove(k)
print(x)
print
Test Case 1
Input (stdin)2 2 100 200 10 20 100
Expected OutputThe Extended List [100, 200, 10, 20] The Reverse List [20, 10, 200, 100] [20, 10, 200]
Test Case 2
Input (stdin)3 3 100 200 300 10 20 30 20
Expected OutputThe Extended List [100, 200, 300, 10, 20, 30] The Reverse List [30, 20, 10, 300, 200, 100] [30, 10, 300, 200, 100]
No comments:
Post a Comment