I need to print the elements of an array from the end to the beginning.
For example, in this case:
array = [0, 10, 20, 40]
for (i = array.length() - 1; i >= 0; i--)
How do I reverse the list?
You can use the reversed function in this case.
>>> for i in reversed(array):
The reversed(....) doesn't return a list though. You can get the reversed list by using list(reversed(array))
ou are using Python 2.x syntax with ...READ MORE
Not sure what your desired output is, ...READ MORE
Well, you are using a complex way. ...READ MORE
Good question - Considering that you are ...READ MORE
suppose you have a string with a ...READ MORE
You can also use the random library's ...READ MORE
colors = ['red', 'green', ...READ MORE
Enumerate() method adds a counter to an ...READ MORE
readline function help to read line in ...READ MORE
Python includes a profiler called cProfile. It ...READ MORE
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.