Skip to content

Commit 7a7a95c

Browse files
committed
Level 06: calc: benötigter Parameter
1 parent 142ede9 commit 7a7a95c

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

Level_06/calc.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ def op_root(a: int, b: int) -> float:
3535

3636

3737
parser = ArgumentParser(description=__doc__)
38-
subparsers = parser.add_subparsers(help="die auszuführende Rechenoperation")
38+
subparsers = parser.add_subparsers(
39+
dest="command",
40+
help="die auszuführende Rechenoperation"
41+
)
42+
subparsers.required = True
3943

4044
for function in (
4145
op_add,
@@ -57,8 +61,5 @@ def op_root(a: int, b: int) -> float:
5761
# Verarbeiten der Argumente
5862
args = parser.parse_args()
5963
# die tatsächliche Funktion aufrufen
60-
if args.func:
61-
res = args.func(args.a, args.b)
62-
print(res)
63-
else:
64-
print("Bitte Anweisung angeben.")
64+
res = args.func(args.a, args.b)
65+
print(res)

0 commit comments

Comments
 (0)