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 185 views
2 answers 221 views
2 answers 166 views
2 answers 208 views
1 answer 158 views
2 answers 230 views
1 answer 163 views
...