Hook
I'm finna teach y'all how to make a switch in Python. Yes bro, a switch. All right, so the first thing we're going to do, we're going to have count equals to 17. And count is equal to the number of rounds we got. So we got 17 rounds in the clip. We're going to use a while loop to unload the clip with a switch on it. If we got to reload the clip, too. In the while loop, we got a cool little if statement. What this if statement is doing is counting down from 17 to zero. It's unloading the clip with a switch. And we added time dot sleep in there so that this runs every 0.1 seconds. Now we got an else statement for when the clip is empty. This is how we're going to reload it. We're going to reset the count back to 17. We're going to print reload and it takes about two seconds to reload. All right, we're going to run this and hit it with the switch. What we created was an infinite loop. We don't want no infinite loop to end. So the lesson here is, make sure you add a break statement so you can stop your while loop. 'Cause they're saying you're getting 10 with a switch.
More breakout videos from this creator.