Python List
Python List
o/p: -
[1, 2, 'Python', 'Progam', 12.3]
['Army', 'Navy', 'Airforce', 'Police']
<class 'list'>
<class 'list'>
Characteristics of Lists: -
The list has some characteristics which
are going to see below.
The lists are ordered sequence.
The elements of the list can
access by index.
The lists are the mutable type.
A list can store the number of
various elements.
Example: -
#list example in details
emp = [“John”, 102, “USA”]
Dep1 = [“CS”,10]
Dep2 =[“IT”,11]
HOD_CS = [10,”Mr.Rahul”]
HOD_IT = [11,”Mr.Balu”]
print(“printing employee data…”)
Print(“Name : %s, ID: %d, Country:
%s” %(emp[0],emp[1],emp[2])
print(“printing departments...”)
print(“Department1:\nName: %s.ID:
%d\n Department2:\nName:%s, ID:
%s”%
(Dep1[0],Dep2[1],Dep2[0],Dep2[1]))
print(“HOD Details…”)
print(“CS HOD Name: %s, id: %d”
% (HOD_CS[1],HOD_CS[0]))
print(“IT HOD Name: %s, id: %d %
(HOD_IT[1],HOD_IT[0]))
o/p: -?
ERROR!
printing employee data…
Traceback (most recent call last):
File "<string>", line 10, in <module>
NameError: name 'Print' is not defined.
Did you mean: 'print'?