Skip to content

Commit 294a6cb

Browse files
committed
fixing the bug : input message more than one word
1 parent f3d6575 commit 294a6cb

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

implement-cowsay/cow.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,14 @@
44

55
parser=argparse.ArgumentParser(prog="cowsay",
66
description="Make animals say things.")
7-
parser.add_argument("message",help="The message to say.")
7+
parser.add_argument("message",nargs="+",help="The message to say.")
88
valid_animals=cowsay.char_names;
99
parser.add_argument("--animal",
1010
choices=valid_animals,
1111
help=" The animal to be saying things.",
1212
default="cow")
1313

1414
args=parser.parse_args();
15-
getattr(cowsay,args.animal)(args.message)
16-
# args=sys.argv[1:]
17-
# print(sys.argv)
18-
# flags=list(filter(lambda arg : arg.startswith("-"),args))
19-
# print(flags)
20-
# validAnimals=cowsay.char_names;
21-
# print(validAnimals)
15+
getattr(cowsay,args.animal)(" ".join(args.message))
2216

23-
# if len(flags)==0 :
24-
# cowsay.cow(" ".join(sys.argv[1:]))
25-
# elif "--help" in flags or "--h" in flags :
26-
# print("help!!!!!!!!!!!!!!!!")
27-
# elif "--animal" in flags :
28-
# animalName=args[args.index("--animal")+1]
29-
# print(animalName)
30-
# message=" ".join(args[args.index("--animal")+2:])
31-
# print(message)
32-
# if hasattr(cowsay,animalName) :
33-
# getattr(cowsay,animalName)(message)
3417

0 commit comments

Comments
 (0)