List operations

 # List operations 

# Components of a car.


Car_Main_components = ['Chassis', 'Engine', {'Body':['Steering system','Braking system','Suspension']}, {'Transmission_System':['Clutch','Gearbox','Differential','Axle']}]


Car_Auxiliaries = ['car lightening system','wiper and washer system','power door locks system','car instrument panel','electric windows system','car park system']


def fnPrint(L):

for ele in L:

if(isinstance(ele,dict)):

for k, v in (ele.items()):

print("\t",k, ":", ", ".join(v))

continue

print("\t",ele)



print("Car Main Components:",)

fnPrint(Car_Main_components)


print("Car Auxiliaries:")

fnPrint(Car_Auxiliaries)


"""

Sample output

>python ListManip.py

Car Main Components:

         Chassis

         Engine

         Body : Steering system, Braking system, Suspension

         Transmission_System : Clutch, Gearbox, Differential, Axle

Car Auxiliaries:

         car lightening system

         wiper and washer system

         power door locks system

         car instrument panel

         electric windows system

         car park system

"""



No comments:

Post a Comment

Don't be a silent reader...
Leave your comments...

Anu