Skip to content

Instantly share code, notes, and snippets.

@gregz67
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save gregz67/00bf29d9611b3298c361 to your computer and use it in GitHub Desktop.

Select an option

Save gregz67/00bf29d9611b3298c361 to your computer and use it in GitHub Desktop.
Programming Club dictionary challenge
__author__ = 'gregz'
# 1. Create a dictionary of three or more of your Minecraft friends.
# The key should be their first name, the value should be their Minecraft login.
# 2. Input a friends name.
# * if the name is in the dictionary, print their Minecraft login.
# * if the name is not in the dictionary
# * print a message saying that name is not in the dictionary
# * input their Minecraft login
# * add it to the dictionary.
minecraft = {
'Greg': 'ZebClan',
'Josh': 'Joe5$9',
'Alex': 'ChezzyBiscuit'
}
name = input('Enter a name: ').capitalize()
if name in minecraft:
print(name + '\'s Minecraft login is: ' + minecraft[name])
else:
print(name + ' is not in my Minecraft dictionary.')
minecraft[name] = input('What is ' + name + '\'s Minecraft login?: ')
print(minecraft)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment