Python Dictionary Items Method
Python dictionary item() method returns a visible object. The visual object contains the dictionary’s key-value pairs, such as tuples in a list. The visual object will reflect any changes made to the dictionary, see the example below.
Python item() method returns a new view of the dictionary. This view is a collection of key-value tuples. This method does not take any parameter and returns an empty view if the dictionary is empty.
Syntax:
dictionary.items()
Example:
x = ([('name', 'pramod'), ('age', 22), ('rollno', '17691a05b9'), ('class', 'B-Tech')])
x = dict(x) # convering into dictionary
y = x.items()
x['age'] = 22
print(y,'\n') # break the line
for key,value in x.items():
print(f'key is {key} and values is {value}')
OutPut
Recommended Post:
- Python Hello World Program
- Python Comment | Creating a Comment | multiline comment | example
- Python Dictionary Introduction | Why to use dictionary | with example
- How to do Sum or Addition in python
- Python Reverse number
- find a common number in python
- addition of number using for loop and providing user input data in python
- Python Count char in String
- Python Last Character from String
- Python Odd and Even | if the condition
- Python Greater or equal number
- Python PALINDROME NUMBER
- Python FIBONACCI SERIES
- Python Dictionary | Items method | Definition and usage
- Python Dictionary | Add data, POP, pop item, update method
- Python Dictionary | update() method
- Delete statement, Looping in the list In Python
- Odd and Even using Append in python
- Python | Simple Odd and Even number
learn salesforce
Python Dictionary Items method Definition and usage