2. Question (5 pt.): We have a list variable 'n' which has integer numbers. For each number in the list, find the number
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
2. Question (5 pt.): We have a list variable 'n' which has integer numbers. For each number in the list, find the number
2. Question (5 pt.): We have a list variable 'n' which has integer numbers. For each number in the list, find the number of smaller numbers in the preceding positions, i.e. if the index of the current elements is i, then preceding elements should have an index less than i. Create the function, i.e., fun_2, to return a list containing for each number in the input list a number of smaller elements in the preceding positions. arg1 = [ 1, 5, 2, 10, 3, 4] output = fun_2(arg1) print(output) [ 0, 1, 1, 3, 2, 3] >>> arg2 = [ 1, 2, 3, 4 ] >>> output = fun_2(arg2) >>>print(output) >>>[0, 1, 2, 3]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!