Advertisements
Advertisements
प्रश्न
Write a function in Python, Push (Vehicle)
where, Vehicle is a dictionary containing details of vehicles – {Car_Name: Maker}
. The function should push the name of car manufactured by 'TATA' (including all the possible cases like Tata, TaTa, etc.) to the stack.
For example:
If the dictionary contains the following data:
Vehicle=["Santro":"Hyundai","Nexon":"TATA","Safari":"Tata"]
The stack should contain
Safari
Nexon
कोड लेखन
उत्तर
def push (Vehicle, stack):
for car_name, maker in vehicle. items ():
if maker, lower() = = " tata" :
stack. append (car_name)
return stack
Vehicle = {"Santro": "Hyundai", "Nexon":TATA, "Safari": "Tata"}
stack=[]
stack = push (Vehicle, stack)
print (stack)
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?