(upbeat music)
- Welcome back.
I hope you had fun thinking of your favorite food
and writing the code for this game.
I know I did,
and here's the solution I came up with.
First, starting on line number one,
I've created a guess variable.
This is where I'm going to store the result
of the user's answer to my question,
what's my favorite food?
Then coming down to line number three,
I start the if statement.
If the user's guess equals cookies,
because of course, cookies is my favorite food,
then I'm going to print out yep, so amazing.
But if the user enters something other than cookies,
I'll fall down to the else statement,
which starts here on line number five,
and I'm going to print what's inside its indented block,
which is yuck, that's not it.
And finally, regardless of what guess the user enters,
I'm going to print thanks for playing.
Let's go ahead and run it
and check out the output.
So we'll right click and we'll come down
to run Python file in terminal as usual.
So let's see, what's my favorite food?
Let's enter cookies.
Yep, so amazing.
Thanks for playing.
And that's it.
Did you come up with something similar?
Maybe you used a different name for your variable,
or maybe you used the not equals operator instead.
That's perfectly fine.
In programming, there's almost always more than one way
to solve a problem.
That's one thing I've always loved about coding.
You get to be creative
and come up with unique solutions to challenging problems.
And now, you're more than halfway through the course.
You should be proud of yourself for hanging in there
and getting to know the basics
of what programming is all about.