1
00:00:05,280 --> 00:00:08,000
In the last video, I'd selected option four,

2
00:00:08,000 --> 00:00:12,160
and we got the list of ingredients for an egg
sandwich. And you can see that on screen here.

3
00:00:12,160 --> 00:00:16,400
If you've been experimenting, to make
sure you understand how a display_dict

4
00:00:16,400 --> 00:00:21,680
and the recipes menus are working together,
then run the program and choose option 4.

5
00:00:21,680 --> 00:00:27,450
At the moment, the program just prints out the list.
We've got egg, butter and bread in the output.  

6
00:00:27,450 --> 00:00:33,360
The next step is to check our pantry dictionary.
If you want to make an egg sandwich, then we'll need

7
00:00:33,360 --> 00:00:39,840
all these three ingredients; egg, bread and butter.
All we have to do is iterate over this list, 

8
00:00:39,840 --> 00:00:45,760
and see if each item is in the pantry dictionary.
I'm not going to set that as a challenge, but if you

9
00:00:45,760 --> 00:00:51,040
want to try that yourself, then pause the video,
and come back when you're ready to see my code.

10
00:00:51,040 --> 00:00:56,279
Alright, so we're going to start now 
by iterating over the items in the list.

11
00:00:57,600 --> 00:01:03,600
So line 25, I'm going to tab over there, and at
the same indentation level, I'm going to type for

12
00:01:03,600 --> 00:01:11,827
food_item in ingredients colon.
So that'll give us each of the ingredients, in turn.

13
00:01:11,827 --> 00:01:15,840
So checking if we've got each ingredient 
is easy. We've seen how to check if something is

14
00:01:15,840 --> 00:01:25,600
in a dictionary, so let's do the same.
So it's if food_item is in pantry colon.

15
00:01:25,600 --> 00:01:32,720
At the moment we'll print a message out - parentheses
f double quotes backslash t. Then we're going to 

16
00:01:32,720 --> 00:01:40,002
put food item in curly braces, and outside of the curly
brace we'll just put OK. Then we'll just close the line.

17
00:01:40,002 --> 00:01:47,074
And we'll put an else here colon and the print
parenthesis f double quotes, backslash t again

18
00:01:47,074 --> 00:01:53,440
for a tab character, and we'll put a message
here: You don't have the necessary ingredient -

19
00:01:53,440 --> 00:01:57,000
or have a necessary ingredient, would be better.

20
00:01:58,080 --> 00:02:02,880
And we'll put food item in curly braces again,

21
00:02:02,880 --> 00:02:06,306
and that's the end of the line.

22
00:02:07,200 --> 00:02:12,080
Alright, so I've put a tab character at the start of
the output, as you saw me do on lines 27 and 29.

23
00:02:12,080 --> 00:02:15,600
That's going to make it easy to see in 
the output, and we'll see that shortly.

24
00:02:15,600 --> 00:02:19,120
There shouldn't be anything else you 
don't understand in that last bit of code.

25
00:02:19,120 --> 00:02:24,582
If the item is in the pantry dictionary - that's 
line 26 - then we print that it's okay. 

26
00:02:24,582 --> 00:02:27,392
Otherwise, we print a message saying we don't have any. 

27
00:02:27,392 --> 00:02:33,443
So let's run the program again now. We're going to item four.

28
00:02:34,480 --> 00:02:39,935
We'll scroll this over a little bit so we can see the whole output.
So egg is okay, as you can see there,

29
00:02:39,935 --> 00:02:45,902
but we haven't got any bread or butter. 
Let's try beans on toast instead - number five.

30
00:02:46,800 --> 00:02:50,160
Well that's not going to be very filling,
we don't have any beans or bread.

31
00:02:50,160 --> 00:02:56,302
I have to be more adventurous with my dinner.
How about chicken and chips? Let's choose option two.

32
00:02:56,939 --> 00:03:03,840
Okay, so we've got chicken. Unfortunately we don't
have any potatoes to make the chips. We also don't

33
00:03:03,840 --> 00:03:10,397
have any salt or vinegar. Now why anyone would put
vinegar on chips is beyond me. it's certainly a British thing.

34
00:03:10,397 --> 00:03:13,760
You're free to modify the recipes, by the way,
if you'd like something like mayonnaise

35
00:03:13,760 --> 00:03:18,800
or ketchup instead. Alright, this point in 
time, I'm hungry so I'm going to get desperate - 

36
00:03:18,800 --> 00:03:24,320
time for choosing option six, or 
to choose option six; Spam a la tin.

37
00:03:24,320 --> 00:03:28,160
And we don't have a tin opener or a spoon. 
I must say, I'm not very disappointed.

38
00:03:28,160 --> 00:03:34,718
Despite the posh name, Spam a la tin doesn't sound
very appetizing. If I've remember the options I've chosen,

39
00:03:34,718 --> 00:03:40,881
that leaves Butter chicken or pizza. 
Option 3 for pizza is OK - let's choose that.

40
00:03:41,760 --> 00:03:46,109
You can see that's OK, and option 
1 for butter chicken should be as well. 

41
00:03:46,109 --> 00:03:49,680
So as you can see, the program has gone 
through all the ingredients for butter chicken,

42
00:03:49,680 --> 00:03:54,247
and checked that they're available. Strangely,
the butter chicken recipe doesn't need butter, 

43
00:03:54,247 --> 00:04:01,120
which is good because we haven't got any. Alright,
so let's terminate the program now by entering zero.

44
00:04:01,120 --> 00:04:04,240
Alright, so this program is very 
good at telling us what we don't have,

45
00:04:04,240 --> 00:04:08,400
but not very good at telling us what to do 
about it. It also doesn't check how much of

46
00:04:08,400 --> 00:04:13,510
an ingredient we have, nor how much we need.
We only have two lemons in the pantry, but that's 

47
00:04:13,510 --> 00:04:17,454
no good if a recipe needs three of them.
We'll continue developing this program.

48
00:04:17,454 --> 00:04:21,786
In the next video,  we'll start by checking
how much of each item, a recipe needs.

49
00:04:21,786 --> 00:04:23,840
See you in the next video.

