+1 vote
in Class 12 by kratos

Write the definition of a function Reverse(X) in Python, to display the elements in reverse order such that each displayed element is the twice of the original element (element * 2) of the List X in the following manner:

Example:

If List X contains 7 integers is as follows:

| X[0] | X[1] | X[2] | X[3] | X[4] | X[5] | X[6] |
| 4 | 8 | 7 | 5 | 6 | 2 | 10 |

After executing the function, the array content should be displayed as follows:

20 4 12 10 14 16 8

1 Answer

+6 votes
by kratos
 
Best answer

def Reverse (X):

for i in range(len (X) -1, -1, -1):

print x[i] *2

...