From 894afd30851e2e290e17a97f38ea8d63716056bb Mon Sep 17 00:00:00 2001 From: Sora Shiratani Date: Wed, 8 Nov 2023 18:36:22 +0900 Subject: [PATCH] Resolve "possibly unbound" error --- example/grover.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/example/grover.py b/example/grover.py index 9ab9894..4681b12 100644 --- a/example/grover.py +++ b/example/grover.py @@ -47,6 +47,9 @@ def grover(v, target, iter): elif len(sys.argv) == 3: n = int(sys.argv[1]) target = q.util.str2binary(sys.argv[2]) + else: + msg = "len(sys.argv) must be 1 or 3" + raise ValueError(msg) iter = 2 ** (n // 2) print("# number of qbits = {}".format(n)) print("# target state = {}".format(q.util.binary2str(n, target)))