To print the key-value pairs from a Python Dictionary (dict) we can make use of the for loop as follows,
weather_data_dict = {
"city": "New York",
"date":"2023-07-04",
"temperature": 23,
"humidity":56
}
for key, value in weather_data_dict.items():
print(key, ":", value)
Output:
city : New York
date : 2023-07-04
temperature : 23
humidity : 56
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Python,
- Python List of Lists with Examples
- Fix: ERROR: Could not find a version that satisfies the requirement tkinter (from versions: none) ERROR: No matching distribution found for tkinter
- How to Convert Python Notebook .ipynb (JSON) to Executable .py Module
- ModuleNotFoundError: No module named qdarkstyle.colorsystem [Python]
- Python: Pandas Merge Indicator (Left, Right and Both) Example
- Fix: EOFError Exception in Python
- How to URL Decode a Query String in Python
- How to take user input from the console in a Python program
- Compare two lists in Python and return matches
- How to change the Python Default version
- Fix: KeyError: exception in Python
- How to get the Execution Time of A Python Program
- Fix: ModuleNotFoundError: No module named boto3 [Python]
- How to get unique values from a list in Python
- How to pip install Python Modules in VSCode
- Python: Fix - TypeError: NoneType object is not iterable
- How to delete a file using Python code example
- How to create a dictionary comprehension in Python
- Python: Get just the filename without extension using Path
- How to comment out a block of code in Python
- How to add two float numbers in Python
- Python: How to POST Json Data with HTTP Request
- Get MD5 Hash as Checksum of a String in Python
- Python - Convert float to String
- How to Parse XML String in Python
More Posts:
- How to Run PowerShell Script (.ps1) on Mac - MacOS
- How to migrate SharePoint Designer 2010 workflow to Power Automate FLOW (Microsoft Office 365) - SharePoint
- Using Java 8 Predicate with 2 Arguments Example - Java
- Microsoft Teams Error code - 6 issue - Teams
- How to connect Relational and NoSQL databases with Spring Boot - HowTos
- How to get file path of a file using Java Code? - Java
- Add Custom External Link to SharePoint Site Navigation - SharePoint
- YAML Parser using Java Jackson Library Example - Java