Friday, 22 July 2022

python3 dict items

 https://www.w3schools.com/python/ref_dictionary_items.asp


The items() method returns a view object. The view object contains the key-value pairs of the dictionary, as tuples in a list.

The view object will reflect any changes done to the dictionary, see example below.


car = {

  "brand": "Ford",

  "model": "Mustang",

  "year": 1964

}


x = car.items()


dict_items([('brand', 'Ford'), ('model', 'Mustang'), ('year', 2018)])

No comments:

Post a Comment