You are on page 1of 1

Assignment on List Function

>> Defined by the square bracket


>> Its Mutable list01[0]= 'Value'

list_01 = ['Prathmesh', 'Kushwaha', 'Male', 25, 82.45, 156.89584]


list_02 = ['Saroj', 'Kushwaha', 'Female', 32, 77.5684, 148.25]
list_03 = ['Kanchan', 'Kushwaha', 'Female', 30, 81.5848, 147.56]

print('\n{0:15} | {1:^10} | {2:8} |{3:^8} | {4:^10} |


{5:^8}'.format('Name','Surname','Gender','Age','Weight','Height'))
print('---------------------------------------------------------------------------'
)
print('{0:15} | {1:10} | {2:8} |{3:^8} | {4:^10.2f} |
{5:^8.2f}'.format(list_01[0],list_01[1],list_01[2],list_01[3],list_01[4],list_01[5]
))
print('{0:15} | {1:10} | {2:8} |{3:^8} | {4:^10.2f} |
{5:^8.2f}'.format(list_02[0],list_02[1],list_02[2],list_02[3],list_02[4],list_02[5]
))
print('{0:15} | {1:10} | {2:8} |{3:^8} | {4:^10.2f} |
{5:^8.2f}'.format(list_03[0],list_03[1],list_03[2],list_03[3],list_03[4],list_03[5]
))

Output :

Name | Surname | Gender | Age | Weight | Height


---------------------------------------------------------------------------
Prathmesh | Kushwaha | Male | 25 | 82.45 | 156.90
Saroj | Kushwaha | Female | 32 | 77.57 | 148.25
Kanchan | Kushwaha | Female | 30 | 81.58 | 147.56

my_list.append('Hindu') >>>> It add the Hindu as last value in the list


my_list.pop() >>> by default last value is removed
my_list.pop(2) >>>> removes the 3rd value in the list
my_list.sort() >>>> sort value if all value are digit
my_list.reverse() >>> That Reverse the current list item

<<<< Nesting Assignement >>>>>

line_01 = [1,2,3]
line_02 = [4,5,6]
line_03 = [7,8,9]
matrix= [line_01, line_02, line_03]

matrix[2][2]= 9

You might also like