Programming with Python

⌘K
  1. Home
  2. Docs
  3. Programming with Python
  4. List, Tuples and Dictiona...
  5. Lists

Lists

Introduction to List:

A list can contain items of same type of items or different types of items

A list is an ordered and indexable sequence of data item.

Declare a list: Separate the items using commas and enclose them with square brackets [ ]

Elements in the list are ordered by their position. Each and every item has its unique index. A list can contain any number of values with different data type such as string, integer, float, real and another list

Example:

List of integer data type

list1 = [2,4,6]

List of different data type

list2=[1,2.0,"XXX"]

Empty list

list3=[]

List of List

list4=[[1,2],list1]
list4 is expanded as [[1, 2], [2, 4, 6]]

Loading

Views: 0

Articles

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments