CODING PRACTICE - 20 Identify the Mistake - Reverse Order - 2
Identify the Mistake - Reverse Order - 2
Given two lists of equal lengths (N), write a program to iterate both lists simultaneously such that the first list should display the item in original order and the second list in reverse order.
Input
The first line of input will contain comma-separated integers.
The second line of input will contain comma-separated integers.
Output
The output should be N rows and 2 columns, the first column should contain the elements of the first list in the original order, and the second column should contain the elements of the second list in the reverse order.
Explanation
For example, if the given two lists are the following.
Print the elements in such a way that the elements of the first list are printed in original order, and the elements of the second list are printed in reverse order. So the output should be as shown below
Input
The first line of input will contain comma-separated integers.
The second line of input will contain comma-separated integers.
Output
The output should be N rows and 2 columns, the first column should contain the elements of the first list in the original order, and the second column should contain the elements of the second list in the reverse order.
Explanation
For example, if the given two lists are the following.
1,2,3
4,5,6
Print the elements in such a way that the elements of the first list are printed in original order, and the elements of the second list are printed in reverse order. So the output should be as shown below
1 6
2 5
3 4
Sample Input 1Sample Output 1
1,2,3 4,5,6
1 6 2 5 3 4
Sample Input 2Sample Output 2
1,3,5,7,9 2,4,6,8,10
1 10 3 8 5 6 7 4 9 2
code:
list_a = input().split(",")
list_b = input().split(",")
len_of_list_a = len(list_a)
n = len_of_list_a - 1
for i in range(len_of_list_a):
num_1 = list_a[i]
num_2 = list_b[n-i]
result = str(num_1) + " " + str(num_2)
print(result)
Comments
Post a Comment