Skip to content

Instantly share code, notes, and snippets.

@blacksheep557
Created January 4, 2021 13:51
Show Gist options
  • Select an option

  • Save blacksheep557/4794509155f68967d3218bb469158189 to your computer and use it in GitHub Desktop.

Select an option

Save blacksheep557/4794509155f68967d3218bb469158189 to your computer and use it in GitHub Desktop.
map_1 = {'1': {'name': 'Binary', 'callback': bin}, '2': {'name': 'Octal', 'callback': oct}}
for conv_id in map_1:
conversion_object = map_1[conv_id]
name = conversion_object['name']
print(f'{conv_id} {name}')
conv_id = input("Enter the conversion : ")
input_number = int(input("Enter the number : "))
conversion_object = map_1[conv_id]
callback = conversion_object['callback']
print(callback(input_number))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment