Return to Snippet

Revision: 51658
at October 3, 2011 04:26 by denakitan


Updated Code
myFavoriteGhibliMoviesReleaseYearDict = {
	'Whisper of the Heart'  : '1995',
	'Princess Mononoke'     : '1997',
	'Spirited Away'         : '2001'
}

if 'Spirited Away' in myFavoriteGhibliMoviesReleaseYearDict:
	print('\'Spirited Away\' release year: ' + myFavoriteGhibliMoviesReleaseYearDict['Spirited Away'])
else:
	print('\'Spirited Away\' release year not found.')

Revision: 51657
at September 30, 2011 23:42 by denakitan


Initial Code
myFavoriteGhibliMoviesReleaseYearDict = {
    'Whisper of the Heart'  : '1995',
    'Princess Mononoke'     : '1997',
    'Spirited Away'         : '2001'
}

if 'Spirited Away' in myFavoriteGhibliMoviesReleaseYearDict:
    print '\'Spirited Away\' release year: ' + myFavoriteGhibliMoviesReleaseYearDict['Spirited Away']
else:
    print '\'Spirited Away\' release year not found.'

Initial URL

                                

Initial Description
Snippet to verify whether or not a key exists in a python dictionary.

Initial Title
Python - Dictionary - Does key exist?

Initial Tags
python

Initial Language
Python