Skip to content

Commit b16105b

Browse files
committed
edited code for better readability
1 parent e7bf176 commit b16105b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

implement-cowsay/anisay.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import argparse
2-
import cowsay
2+
import cowsay #to do the ascii art with animals
33

44
def main():
5+
#getlistof animals within cowsay
56
animals = cowsay.char_names
7+
#create a parser for command line argument
68
parser = argparse.ArgumentParser(
79
description="Make animals say things!"
810
)
@@ -12,8 +14,11 @@ def main():
1214
default='cow',
1315
help='The animal to be saying things (default: cow)'
1416
)
17+
#argument for the message
1518
parser.add_argument('message',nargs='+',help='The message to say')
19+
#to parse the arguments from the command line
1620
args = parser.parse_args()
21+
#the messageword into a single string
1722
text = ' '.join(args.message)
1823

1924
try:
@@ -22,6 +27,6 @@ def main():
2227
except cowsay.CowsayError as e:
2328
print(f"Error: {e}")
2429
exit(1)
25-
30+
#run main function only if this script is run directly
2631
if __name__ == '__main__':
2732
main()

0 commit comments

Comments
 (0)