Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Dictionary get both key and value.

# Loop thru a dictionary, get both key and value.

dd = {'john':3, 'mary':4, 'joe':5, 'vicky':7}

for kk, vv in dd.items():
    print(kk, ' is ', vv)

# john  is  3
# mary  is  4
# joe  is  5
# vicky  is  7
Comment

Dictionary get both key and value.

# get value of given key

hh = {"a":1, "b":2}

print(hh.get("b")) # 2

print(hh.get("x")) # None

print(hh.get("x", 8)) # 8
Comment

PREVIOUS NEXT
Code Example
Python :: stores number in set using input in python 
Python :: how to interrupt a loop in python 
Python :: discord.py add avatar to embed 
Python :: search whole drive for a file in python 
Python :: unity python 
Python :: find the median of input number in a list and print 
Python :: decimal hour to hour minute python 
Python :: to_datetime with non zero padded values python 
Python :: plot the distribution of value_counts() python 
Python :: Flask / Python. Get mimetype from uploaded file 
Python :: declare array python 
Python :: create database tables python 
Python :: wails install 
Python :: multithreaded programming in python 
Python :: truncate spaces in python 
Python :: python second element of every tuple in list 
Python :: Exiting from python Command Line 
Python :: get python ssl certificate location 
Python :: Python NumPy transpose Function Syntax 
Python :: Python use number twice without assignment 
Python :: python filter list 
Python :: cannot create group in read-only mode. keras 
Python :: Acticating virtual environment 
Python :: python get website chrome network tab 
Python :: python open file check error 
Python :: import statsmodels as sm 
Python :: python string formatting - padding 
Python :: class chain methods python 
Python :: python normalized correlation 
Python :: flask get with parameters 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =