You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ff82bc0
Browse filesBrowse the repository at this point in the historyBrowse files
## Merge or Update Dictionaries Via the Union (`|`) Operators
191
+
## Merge or Update Dictionaries Using Union (`|` and `|=`) Operators
192
192
193
193
Python 3.9 introduces a different means of merging `dicts`: the `union` operators.
194
194
`dict_one | dict_two` will create a **new dictionary**, made up of the (`key`, `value`) pairs of `dict_one` and `dict_two`.
@@ -271,7 +271,7 @@ Unless a _sort key_ is specified, the default sort is over dictionary `keys`.
271
271
'Misty Mountain Pink': '#f9c5bd'}
272
272
```
273
273
274
-
## Transposing a Dictionaries Keys and Values
274
+
## Transposing Dictionary Keys and Values
275
275
276
276
Swapping keys and values reliably in a dictionary takes a little work, but can be accomplished via a `loop` using `dict.items()` or in a dictionary comprehension.
277
277
Safe swapping assumes that `dict` keys and values are both _hashable_.
Copy file name to clipboardExpand all lines: exercises/concept/mecha-munch-management/.docs/hints.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,13 +9,13 @@ It's OK to be simple and direct with the functions you are writing.
9
9
The dictionary section of the [official tutorial][dicts-docs] and the mapping type [official library reference][mapping-types-dict] are excellent places to look for more help with all these methods.
10
10
11
11
12
-
## 1. Add Item(s) to the Users Shopping Cart
12
+
## 1. Add Item(s) to the User's Shopping Cart
13
13
14
14
- You will need to iterate through each item in `items_to_add`.
15
15
- You can avoid a `KeyError` when a key is missing by using a `dict`[method][set-default] that takes a _default value_ as one of its arguments.
16
16
- It is also possible to accomplish the same thing manually in the `loop` by using some checking and error handling, but the `dict` method is easier.
17
17
18
-
## 2. Read in Items Listed in the Users Notes App
18
+
## 2. Read in Items Listed in the User's Notes App
19
19
20
20
- Remember, Python's got a method for _everything_. This one is a _classmethod_ that's an easy way to [populate a `dict`][fromkeys] with keys.
21
21
- This `dict` method returns a _new dictionary_, populated with default values. If no value is given, the default value will become `None`
@@ -25,13 +25,13 @@ The dictionary section of the [official tutorial][dicts-docs] and the mapping ty
25
25
- Don't overthink this one! This can be solved in **one**`dict` method call.
26
26
- The key word here is .... [_update_][update].
27
27
28
-
## 4. Sort the Items in the User Cart
28
+
## 4. Sort the Items in the User's Cart
29
29
30
30
- What method would you call to get an [iterable view of items][items] in the dictionary?
31
31
- If you had a `list` or a `tuple`, what [`built-in`][builtins] function might you use to sort them?
32
32
- The built-in function you want is the one that returns a _copy_, and doesn't mutate the original.
33
33
34
-
## 5. Send User Shopping Cart to Store for Fulfillment
34
+
## 5. Send the User's Shopping Cart to the Store for Fulfillment
35
35
36
36
- Having a fresh, empty dictionary here as the `fulfillment_cart` might be handy for adding in items.
37
37
-`Looping` through the members of the cart might be the most direct way of accessing things here.
Copy file name to clipboardExpand all lines: exercises/concept/mecha-munch-management/.docs/instructions.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
# Instructions
2
2
3
-
Mecha Munch™, a grocery shopping automation company has just hired you to work on their ordering app.
3
+
Mecha Munch™, a grocery shopping automation company, has just hired you to work on their ordering app.
4
4
Your team is tasked with building an MVP (_[minimum viable product][mvp]_) that manages all the basic shopping cart activities, allowing users to add, remove, and sort their grocery orders.
5
5
Thankfully, a different team is handling all the money and check-out functions!
6
6
7
-
## 1. Add Item(s) to the Users Shopping Cart
7
+
## 1. Add Item(s) to the User's Shopping Cart
8
8
9
9
The MVP should allow the user to add items to their shopping cart.
10
10
This could be a single item or multiple items at once.
@@ -26,12 +26,12 @@ It should return a new/updated shopping cart dictionary for the user.
## 2. Read in Items Listed in the User's Notes App
30
30
31
31
Uh-oh.
32
32
Looks like the product team is engaging in [feature creep][feature creep].
33
33
They want to add extra functionality to the MVP.
34
-
The application now has to create a shopping cart by reading items off a users notes app.
34
+
The application now has to create a shopping cart by reading items off a user's notes app.
35
35
Convenient for the users, but slightly more work for the team.
36
36
37
37
Create the function `read_notes(<notes>)` that can take any list-like iterable as an argument.
@@ -97,7 +97,7 @@ Create the function `sort_entries(<cart>)` that takes a shopping cart/dictionary
97
97
98
98
## 5. Send User Shopping Cart to Store for Fulfillment
99
99
100
-
The app needs to send a given users cart to the store for fulfillment.
100
+
The app needs to send a given user's cart to the store for fulfillment.
101
101
However, the shoppers in the store need to know which store aisle the item can be found in and if the item needs refrigeration.
102
102
So (_rather arbitrarily_) the "fulfillment cart" needs to be sorted in reverse alphabetical order with item quantities combined with location and refrigeration information.
0 commit comments