• Register
0 votes
97 views

Problem :

Facing following issue related to list in Python

given that a refers to a list, write the necessary code to reverse the elements of the list.

6.9k points

1 Answer

0 votes

Solution :

Please find your solution as follows:
>>> L = [0,10,20,30,40]
>>> L.reverse()
>>> L
[40,30, 20, 10, 0]

Or

>>> L[::-1]
[40,30, 20, 10, 0]
36.1k points

Related questions

0 votes
2 answers 87 views
87 views
Problem : I need solution for below problem using Python Given that play_list has been defined to be a list, write a statement that sorts the list.
asked Nov 24, 2019 alecxe 7.5k points
0 votes
2 answers 54 views
54 views
Problem : Python Program to Calculate the Average of Numbers in a Given List
asked Oct 21, 2019 peterlaw 6.9k points
0 votes
2 answers 9 views
9 views
Problem: Given the array a, write an expression that refers to the first element of the array?
asked Apr 12 ArifulIslam 5.7k points
0 votes
1 answer 11 views
11 views
Problem: Given an ArrayList a, write an expression that refers to the first element of the ArrayList?
asked Apr 12 ArifulIslam 5.7k points
1 vote
1 answer 16 views
16 views
Problem: Recently I started learning python and just about to know more about list and tuple in python. I am a little bit known to the list and tuple and I can add or subtracts elements in a list. I wonder how to multiply all elements in a list python? I tried it in the adding process but it didn’t work for me. Is it doable? Could anybody please show me the way to do it?
asked Apr 3 Gavin 15.2k points