#Working with Lists in Python - Tutorial
This tutorial was built in Python 3.6
A Simple List
my_list = [1, 2, 3, 4]
print(my_list)
Reversing a List
This quick and easy technique shows how you can access all the elements of a list in reverse order.
>>> my_list = [1,2,3,4,5]
>>> my_list[::-1]
[5, 4, 3, 2, 1]
Try it Out
my_list = [1, 2, 3, 4]
print(my_list[::-1])
We can then treat our reversed list as an iterator and iterate through every
element within this reversed list like so:
>>> for el in my_list[::-1]:
... print(el)
...
5
4
3
2
1
Conclusion
If you found this tutorial useful or require further assistance then please let me know in the comments section below or by tweeting me: @Elliot_F.
Continue Learning
Working With The File System in Python
In this tutorial we evaluate the different ways you can work with the file system in Python
Getting Started With Python
An absolute beginners introduction to the Python programming language
Functions and Variables in Python
In this tutorial we introduce the concept of both functions and variables and how we can use them in our Python programs
Reading and Writing Files In Python
In this tutorial we'll be looking at how you can manipulate and read from files using the Python programming language.