• Register
0 votes
203 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

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]
38.6k points

Related questions

0 votes
2 answers 260 views
260 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
1 answer 18 views
18 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
1 answer 19 views
19 views
Problem: I have no idea to solve this, somebody help : Given a list named play_list, write an expression whose value is the length of play_list.
asked Jun 12 asha 121k points
0 votes
1 answer 12 views
12 views
Problem: How can I reverse a list in Python?
asked Apr 13 ummesalma 29.1k points
0 votes
2 answers 94 views
94 views
Problem: Given the array a, write an expression that refers to the first element of the array?
asked Apr 12, 2020 ArifulIslam 9.9k points
0 votes
1 answer 38 views
38 views
Problem: Given an ArrayList a, write an expression that refers to the first element of the ArrayList?
asked Apr 12, 2020 ArifulIslam 9.9k points
0 votes
1 answer 33 views
33 views
Problem: I was trying to solve a problem in Codility provided below, Write a function: class Solution { public int solution(int[] A); } that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A. For example, given A = [1, 3, 6, 4, 1, 2], the function ... for (int i = 0; i < N; i++) { if (C[i] != 0) { return (i + 1); } } return (N + 1); }
asked Apr 25 sumaiya simi 43.9k points
0 votes
1 answer 13 views
13 views
Problem: Is there anyone who knows the answer: Write a program that reads in a list of integers into an array with base type int?
asked Jun 13 Nahil 128k points
0 votes
1 answer 7 views
7 views
Problem: Python take first n elements of list.
asked 2 days ago Shima 126k points
0 votes
1 answer 6 views
6 views
Problem: Sum of all elements in a list python
asked 6 days ago asha 121k points