Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #replace #dictionary
ADD COMMENT
Topic
Name
1+4 =