Listing 06-24: Example of a dictionary with a default value

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 06\06.24 - Example of a dictionary with a default value.py
# Description: Example of a dictionary with a default value
##############################################################################

d = {}
for letter in "abracadabra":
    d[letter] = d.get(letter, 0) + 1
print(d)
Click here to download the file