-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForLoopAndFormat Python
More file actions
9 lines (7 loc) · 974 Bytes
/
ForLoopAndFormat Python
File metadata and controls
9 lines (7 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
# Provided is a list of data about a store’s inventory where each item in the list represents the name of an item, how much is in stock,
# and how much it costs. Print out each item in the list with the same formatting, using the .format method (not string concatenation).
# For example, the first print statment should read The store has 12 shoes, each for 29.99 USD.
inventory = ["shoes, 12, 29.99", "shirts, 20, 9.99", "sweatpants, 25, 15.00", "scarves, 13, 7.75"]
for item in inventory:
item = item.split(", ")
print("The store has {} {}, each for {} USD.".format(item[1], item[0], item[2]))Provided is a list of data about a store’s inventory where each item in the list represents the name of an item, how much is in stock, and how much it costs. Print out each item in the list with the same formatting, using the .format method (not string concatenation). For example, the first print statment should read The store has 12 shoes, each for 29.99 USD.