• Register
0 votes
149 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 5 3
6,930 points

Please log in or register to answer this question.

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]
9 7 4
38,600 points

Related questions

0 votes
2 answers 179 views
179 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 44 views
44 views
Problem: Given the array a, write an expression that refers to the first element of the array?
asked Apr 12, 2020 ArifulIslam 7.5k points
0 votes
1 answer 27 views
27 views
Problem: Given an ArrayList a, write an expression that refers to the first element of the ArrayList?
asked Apr 12, 2020 ArifulIslam 7.5k points
0 votes
1 answer 6 views
6 views
Problem: how to Solve this: error: term refers to an individual item in a list. HELP! I need help understanding this: term refers to an individual item in a list. Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked Mar 11 Mashhoodch 13k points
0 votes
2 answers 757 views
757 views
Problem : Python Program to Calculate the Average of Numbers in a Given List
asked Oct 21, 2019 peterlaw 6.9k points
0 votes
1 answer 1 view
1 view
Problem: Python number of elements in a list.
asked 11 hours ago Dan phillip 4.7k points
0 votes
1 answer 10 views
10 views
Problem: For a list ["foo","bar","baz"]and a list item "bar", what is the cleanest way to get its index (1) in python?
asked Feb 27 sasha 16.2k points
1 vote
1 answer 55 views
55 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, 2020 Gavin 15.3k points
0 votes
1 answer 10 views
10 views
Problem: Is this the cleanest way to write a list to a file, since writelines() doesn't insert newline characters? file.writelines(["%s\n" % item for item in list]) It seems like there would be a standard way...
asked Feb 17 Mashhoodch 13k points
0 votes
1 answer 156 views
156 views
Problem : I am facing below python list problem design a program that lets the user enter the total rainfall for each of 12 months into an array
asked Nov 12, 2019 peterlaw 6.9k points