Write a program to append two list and calculate the length of the list. Kindly refer sample input and output for the task
Input:
- The Size of First List
- The Size of Second List
- First List elements
- Second List elements
- First List Element to be searched
- Second List Element to be searched
- Index number of the list to be added
- Element to be added in the list (Step 7)
Output:
- Extended List or appended list
- The index of the first list element (entered by user, Step 5)
- The index of the second list element (entered by user, Step 6)
- The updated list after inserting the element (entered by user in step 7 and 8)
Refer sample input and output for formatting specification.
N1=int(input("Enter the size of first list: ")) N2=int(input("Enter the size of second list: ")) l1=[] l2=[] print('Enter the first list elements: ') for i in range(N1): l1.append(int(input(''))) print('Enter the second list elements: ') for i in range(N2): l2.append(int(input(''))) s1=int(input('First List Element to be searched: ')) s2=int(input('Second List Element to be searched: ')) ind=int(input('Index number of the list to be added: ')) ele=int(input('Element to be added in the list:')) l3=l1+l2 print('The Extended List') print(l3) print('Index for {} = {}'.format(s1,l3.index(s1))) print('Index for {} = {}'.format(s2,l3.index(s2))) print('After Inserting') l3.insert(ind,ele) print(l3)
Input_1:
Enter the size of first list: 2
Enter the size of second list: 2
Enter the first list elements:
25
23
Enter the second list elements:
9
20
First List Element to be searched: 25
Second List Element to be searched: 20
Index number of the list to be added: 1
Element to be added in the list:2509
Output:
The Extended List
[25, 23, 9, 20]
Index for 25 = 0
Index for 20 = 3
After Inserting
[25, 2509, 23, 9, 20]
Input_2:
Enter the size of first list: 3
Enter the size of second list: 3
Enter the first list elements:
81
71
61
Enter the second list elements:
10
20
30
First List Element to be searched: 81
Second List Element to be searched: 30
Index number of the list to be added: 4
Element to be added in the list:252025
Output:
The Extended List
[81, 71, 61, 10, 20, 30]
Index for 81 = 0
Index for 30 = 5
After Inserting
[81, 71, 61, 10, 252025, 20, 30]
Exec. on linux
Morae!Q!
- Insert and Extend in list
- Interchange first and last number in list
- Print Odd Numbers in range
- Compare List in python
- Find whether the largest element in the array is at least twice as much as every other number in the array.
- Find minimum cost to reach the top of the floor
- Word Count in Python
- Lower case to upper case in python
- Display Time in python
- Sum of Odd And Even in Python
- Surface Area of Walls
- Find the sum of squares of individual digits
- Print the given series – 1 1 2 6 24
- Minimum number of steps required to reach destination.
- Seconds to Days Hours Minutes
- Program to remove add “Hyphen” character in the entered string
- Remove the nth Index Character from a Non-Empty String
- Relational operator Question
- Check whether all the given numbers lies in range of x and y.
- Find the Armstrong numbers between the given range.