
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How to pass a dictionary as argument in Python function?
In the code given below we pass given dictionary as an argument to a python function and then call the function which works on the keys/value pairs and gives the result accordingly
Example
d = {'a' : 1, 'b' : 2, 'c' : 3} def f(dict): for k, v in dict.iteritems(): print k, 2*v f(d)
Output
a 2 c 6 b 4
- Related Articles
- How to pass Python function as a function argument?
- Java Program to Pass ArrayList as the function argument
- How to pass entire array as an argument to a function in C language?
- How to pass entire structure as an argument to function in C language?
- How to pass an entire structure as an argument to function in C?
- How to pass the address of structure as an argument to function in C?
- How to pass individual elements in an array as argument to function in C language?
- How to pass the address of structure as an argument to function in C language?
- How to pass argument to an Exception in Python?
- Java Program to pass lambda expression as a method argument
- How to pass a json object as a parameter to a python function?
- How to pass a function as a parameter in Java
- Can we pass objects as an argument in Java?
- Python Program to pass the tuple as function arguments
- How to call a function with argument list in Python?

Advertisements