Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python replace by dictionary

address = "123 north anywhere street"

for word, initial in {"NORTH":"N", "SOUTH":"S" }.items():
    address = address.replace(word.lower(), initial)
print address
Comment

replace key of dictionary python

a_dict = {"a": 1, "B": 2, "C": 3}

new_key = "A"
old_key = "a"
a_dict[new_key] = a_dict.pop(old_key)

print(a_dict)
OUTPUT
{'B': 2, 'C': 3, 'A': 1}
Comment

PREVIOUS NEXT
Code Example
Python :: ring For in Loop 
Python :: ring Search List Item 
Python :: ring add new items to the list using the string index 
Python :: ring get the windows new line string 
Python :: ring Using This in the class region as Self 
Python :: store image in django postprocessimage in django storage 
Python :: ring Load Syntax Files 
Python :: ring Trace library usage to pass an error 
Python :: echo linux with ANSI escape sequence for change output color 
Python :: remove kernel 
Python :: ret, img_frame = cap.read() 
Python :: module not found after sucessful install 
Python :: how to download feature engine in spyder console 
Python :: python launch ipython from script 
Python :: python mayusculas 
Python :: y level for iron 
Python :: modwt python github code 
Python :: pico 8 pset 
Python :: qcombobox remove all items 
Python :: python loop over lists 
Python :: entry point not found python.exe 
Python :: logistic regresion heart disease python 
Python :: set application taskbar icon 
Python :: aw mustard 
Python :: run selenium webdriver without opening browser 
Python :: make setup file for cython 
Python :: break statement python 
Python :: mysql insert into python many 
Python :: double linked list python 
Python :: generate a random string with lowercase uppercase and numbers 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =