Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c3007e1

Browse files
committed
ch03: cleanup
1 parent de3e87e commit c3007e1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

03_picnic/picnic.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get_args():
1717
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
1818
)
1919

20-
parser.add_argument("items", metavar="str", help="Item(s) to bring", nargs="+")
20+
parser.add_argument("item", metavar="str", help="Item(s) to bring", nargs="+")
2121

2222
parser.add_argument("-s", "--sorted", help="Sort the items", action="store_true")
2323

@@ -29,12 +29,12 @@ def main():
2929
"""Make a jazz noise here"""
3030

3131
args = get_args()
32-
sort_flag = args.sorted
33-
items = args.items
32+
items = args.item
3433

35-
if sort_flag == True:
34+
if args.sorted == True:
3635
items.sort()
3736

37+
items_to_bring = ""
3838
if len(items) >= 3:
3939
items.insert(-1, "and ")
4040
items_to_bring = ", ".join(items[:-1]) + items[-1]
@@ -43,7 +43,7 @@ def main():
4343
else:
4444
items_to_bring = items[0]
4545

46-
print("You are bringing " + items_to_bring + ".")
46+
print(f"You are bringing {items_to_bring}.")
4747

4848

4949
# --------------------------------------------------

0 commit comments

Comments
 (0)