In this new activity, you will take an input from the user, let's say 0 or 1, and if the user gives
you zero, you turn off the LED.
If the user gives you one, you turn on the LED.
So here zero means turn off and then one means turn on.
And you're going to use the input function okay that we have seen previously.
So you will have first to set up the LED with the Gpio zero module like we did in the previous lesson.
And then to get the number from the user you can use the input with a nice input message.
So you can put a message here so the instruction is clear.
Then you can put this input result inside a variable for example user choice like this.
And of course don't forget to cast to an int.
So the whole thing because what you're going to get is a string that you want to cast to an int, okay,
to get 0 or 1.
So after you get the input, what you can do as an additional step is to validate Date that input.
Why we validate that input?
Because we are expecting 0 or 1.
But if the user gives you -1 or 10 or any other number, well, that's not valid.
You want to have exactly 0 or 1.
So if it's zero you turn off.
If it's one, you turn on.
If it's any other value, you're going to print an error message and you're going to exit the program.
To exit the program, you also have this keyword exit.
So if I write exit and the Python interpreter reaches that line, then it's just going to exit from
the program, even if I have additional instructions after that.
So if I have anything else, for example minus six then we're gonna print a log and exit.
So not just minus six, it's just an example but any other number.
And well, after you turn off or you turn on, maybe you wait for two seconds.
Okay.
So you can wait for two seconds before you finish the program.
And that's basically it.
Okay.
So with this you will practice with the LED but also with conditions.
All right.
Now I will see you in the next lesson for the solution.