def melon_output(melon_name): """This function takes the name of a melon in the dictionary and prints the data about it""" # assigns 'melon' and 'attributes' to each the key/value pair in the 'melon_data' dictionary, and then 'category' # and 'value' for each key/value pair in the 'attributes' dictionary nested as a value inside 'melon_data'. # Prints each key/value pair in a readable format. for melon, attributes in melon_data.items(): for category, value in attributes.items(): print category, ":", value break
def print_melon(melon_data): """Print each melon with corresponding attribute information.""" for melon_name, attributes in melon_data.items(): print(melon_name.upper()) for attribute, value in attributes.items(): print(f'{attribute}: {value}') print("---------------------------------")
def print_melon(melon_data): for melon, attributes in melon_data.items(): print melon for attribute, value in attributes.items(): print "{}: {}".format(attribute, value) print \
def print_melon_data(melon_data): for melon, attributes in melon_data.items(): print melon for attribute, value in attributes.items(): print "%s : %s " % (attribute, value) print '\n'
# """Print out all the melons in our inventory.""" from melons import melon_data def print_melon(melon_data): """Print each melon with corresponding attribute information.""" for melon, data in melon_data.items(): print(melon) for key in data: print(key + ':', data[key]) # # Used this source for guidance: # # https://www.learnbyexample.org/python-nested-dictionary/