How to remove an arbitrary (key, value) pair from the dictionary in Python

1 Answer

0 votes
dic = {'a': 'python', 'b': 'java', 'c': 'php', 'd': "c#"}

dic.popitem()
dic.popitem()

print(dic)


'''
run:

{'a': 'python', 'd': 'c#'}

'''

 



answered Dec 5, 2017 by avibootz

Related questions

1 answer 150 views
2 answers 176 views
2 answers 131 views
2 answers 163 views
1 answer 133 views
2 answers 189 views
1 answer 135 views
...