# Dictionaries are data structures that are
# a bit easier to understand
moth_counts_dict = {'Hawk':28, 'Carpet':57, 'Pug':32}
# print individual entries and summary
print('We have ' + str(len(moth_counts_dict)) + ' moth types')
all_moths = list(moth_counts_dict)
print('The third moth type being ' + all_moths[2])
...
# dictionaries can be edited by ...
# adding
moth_counts_dict['Snout'] = 18
#deleting
del moth_counts_dict['Pug']
# overwriting
moth_counts_dict['Carpet'] = 18
...
# running total using loop
moth_sum = 0
all_moths = list(moth_counts_dict)
for curr_moth in all_moths:
moth_sum = moth_sum + moth_counts_dict[curr_moth]
print('In total ' + str(moth_sum) + ' moths')
# check if a moth is present
check_moth = input('Type moth search here - hint: Just answer Snout )')
if check_moth in moth_counts_dict:
print('yay we have a ' + check_moth)
else:
print('Missed!')