226,007 views
3 votes
3 votes
create a dictionary with at least five key-value pairs. use strings for either the keys, the values, or both. on a single line, display your dictionary's keys and values, with a comma between each pair. modify one of the values in your dictionary. on a single line, display your dictionary's keys and values, with a comma between each pair. delete one of the key-value pairs from your dictionary. on a single line, display your dictionary's keys and values, with a comma between each pair. print a blank line. display your dictionary's keys, one per line. print a blank line. display your dictionary's values, one per line. do not print curly braces, quotation marks, or colons. do not hard code anything in your print statements! do not use my key-value pairs. choose your own! for extra credit, do not print the trailing (final) comma on each of the first three lines of output.

User Ameer Sheikh
by
2.8k points

2 Answers

15 votes
15 votes
From 1 to 4 red gets removed
User Gustavodidomenico
by
3.1k points
13 votes
13 votes

Answer:

def dictionary_remove():

dict = {'blue':1,'red':2,'green':3}

print(dict)

dict['blue'] = 4

print(dict)

del dict['red']

print(dict)

dictionary_remove()

Explanation: This is a function that meets the requirements of the instructions. First, it creates a dictionary with the key values 'red', 'green', and 'blue' and assigns each of them a number. After it changes blue from 1 to 4 and then gets rid of the red.

User Mspaja
by
3.4k points