पायथन डिक्शनरी पॉप () विधि
उदाहरण
शब्दकोश से "मॉडल" निकालें:
car = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
car.pop("model")
print(car)
परिभाषा और उपयोग
pop()
विधि शब्दकोश से निर्दिष्ट आइटम को हटा देती है ।
हटाए गए आइटम का मूल्य pop()
विधि का वापसी मूल्य है, नीचे उदाहरण देखें।
वाक्य - विन्यास
dictionary.pop(keyname, defaultvalue)
पैरामीटर मान
Parameter | Description |
---|---|
keyname | Required. The keyname of the item you want to remove |
defaultvalue | Optional. A value to return if the specified key do not exist. If this parameter is not specified, and the no item with the specified key is found, an error is raised |
और ज्यादा उदाहरण
उदाहरण
हटाए गए आइटम का मूल्य पॉप () विधि का वापसी मूल्य है:
car = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
x = car.pop("model")
print(x)