From 0fcbaa442f538c8ffca8a7387f7dc6d280172a5c Mon Sep 17 00:00:00 2001 From: John R. Lenton Date: Mon, 6 Jan 2014 19:48:34 +0000 Subject: implemented dict.pop --- tests/basics/tests/dict_pop.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/basics/tests/dict_pop.py (limited to 'tests') diff --git a/tests/basics/tests/dict_pop.py b/tests/basics/tests/dict_pop.py new file mode 100644 index 000000000..602560ce9 --- /dev/null +++ b/tests/basics/tests/dict_pop.py @@ -0,0 +1,12 @@ +d = {1: 2, 3: 4} +print(d.pop(3), d) +print(d) +print(d.pop(1, 42), d) +print(d.pop(1, 42), d) +print(d.pop(1, None), d) +try: + print(d.pop(1), "!!!",) +except KeyError: + print("Raised KeyError") +else: + print("Did not rise KeyError!") -- cgit v1.2.3