We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 142ede9 commit 7a7a95cCopy full SHA for 7a7a95c
1 file changed
Level_06/calc.py
@@ -35,7 +35,11 @@ def op_root(a: int, b: int) -> float:
35
36
37
parser = ArgumentParser(description=__doc__)
38
-subparsers = parser.add_subparsers(help="die auszuführende Rechenoperation")
+subparsers = parser.add_subparsers(
39
+ dest="command",
40
+ help="die auszuführende Rechenoperation"
41
+)
42
+subparsers.required = True
43
44
for function in (
45
op_add,
@@ -57,8 +61,5 @@ def op_root(a: int, b: int) -> float:
57
61
# Verarbeiten der Argumente
58
62
args = parser.parse_args()
59
63
# die tatsächliche Funktion aufrufen
60
- if args.func:
- res = args.func(args.a, args.b)
- print(res)
- else:
64
- print("Bitte Anweisung angeben.")
+ res = args.func(args.a, args.b)
65
+ print(res)
0 commit comments