🎓 Welcome back to Digital Academy, the Complete Python Development Tutorial for Beginners, which will help you Learn Python from A to Z!
🖥️ How to create a List in Python?
There are several ways to create a new list. In Python programming language, the simplest way to create a list is: to enclose all the items, also known as elements, inside square brackets [] - and separated by commas. It can have any number of items inside, and they may even be of different Data Types - integer, float, string, boolean, or even another nested list, which contains other items of different data types, and so forth.
Let's have a closer look at its syntax, so you can declare your own list. Here is an example, in which you want to store a list of strings. First, Let's declare an empty list - with empty brackets []. Eventually, you will add all of the strings, so that you can store and then access its values, later on.
Empty list
my_list = []
List of integers
my_list = [1, 2, 3]
List of strings
my_list = ['red', 'green', 'blue']
List with mixed data types
my_list = [1, "Hello", 3.4, True, [1, 2, 3]]
A list containing zero items is called an empty list, and you can create one with empty brackets []. But, you can also use the list() constructor to declare a new list in Python, or even convert other data types - like string or tuples, into a list.
Convert string - list
my_list = list('abc')
Convert tuple - list
my_list = list((1, 2, 3))
Let's play this video, stick around and watch until the end of this video! 👍🏻
Digital Academy™ 🎓
***
☞ WATCH NEXT:
○ Data Types in Python - • DATA TYPES in Python (Numbers, String...
○ Operators in Python - • OPERATORS in Python (Arithmetic, Assi...
○ IF Statements in Python - • CONDITIONAL Statements in Python (IF,...
○ FOR Loops in Python - • FOR Loop in Python (Syntax, Break, Co...
📖 Blog: http://digital.academy.free.fr/blog
📖 [FULL Course] HOW TO Learn Python? Python Tutorial for Beginners: • 🐍 Python 101: Learn Python Basics for...
📖 [PLAYLIST] Complete Python Development Course for Beginners: http://digital.academy.free.fr/playli...
🧑🎓 [COURSE] http://digital.academy.free.fr/courses
📘 [BOOK] Python for Absolute Beginners: https://amzn.to/3NvyOWV
🛒 Shopping and Discounts: http://digital.academy.free.fr/store
💌 Weekly Newsletter for Developers: https://www.getrevue.co/profile/digit...
#Python #Tutorial #Beginners #Shorts
***
♡ Thanks for watching and supporting ♡
Please Subscribe. Hit the notification bell.
Like, Comment and Share.
***
♡ FOLLOW US ♡
✧ http://digital.academy.free.fr/
✧ / digitalacademyy
✧ / digitalacademyfr
✧ / digital_academy_fr
✧ / digitalacademyonline
♡ SUPPORT US ♡
✧ http://digital.academy.free.fr/join
✧ http://digital.academy.free.fr/store
✧ http://digital.academy.free.fr/donate
✧ http://digital.academy.free.fr/subscribe
✧ / digital_academy
✧ https://www.buymeacoffee.com/digital_...
***
On this page of the site you can watch the video online How to create a List in Python? - Python Tutorial for Beginners with a duration of hours minute second in good quality, which was uploaded by the user Digital Academy 11 March 2021, share the link with friends and acquaintances, this video has already been watched 487 times on youtube and it was liked by 14 viewers. Enjoy your viewing!