Skip to content

Instantly share code, notes, and snippets.

@Sukhrobjon
Last active May 8, 2019 21:41
Show Gist options
  • Select an option

  • Save Sukhrobjon/b409cf8efd9a4c7e6e7e4d8cb09df954 to your computer and use it in GitHub Desktop.

Select an option

Save Sukhrobjon/b409cf8efd9a4c7e6e7e4d8cb09df954 to your computer and use it in GitHub Desktop.
This is sample code for medium article for CS-1.3 class at Make School
# declaring the dictionary with keys and values
dict_nums = {'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5}
print(dict_nums) # {'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5}
# extracting the keys and putting in a list
list_keys = list(dict_nums.keys())
print(list_keys) # ['one', 'two', 'three', 'four', 'five']
# creating set with same items as keys of the dictionary
set_num = set(['one', 'two', 'three', 'four', 'five'])
print(set_num) # {'five', 'four', 'one', 'three', 'two'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment