From the course: Python Essential Training

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

If and else

If and else

If you want to learn about conditional statements in Python, you're in the right place. Else? Well, you should learn about conditional statements in Python. They're critical to writing most programs. And although we covered if and else previously, now we're going to show you a new statement you can add on to these if and else blocks, as well as a new syntax for using the if statement. If you've done any other programming languages, you've probably encountered the switch statement. You evaluate a series of values the code instructions that correspond to the first true value you find. And if you've never heard of a switch statement and don't know what I'm talking about, that's fine. Obviously, other programming languages are inferior to Python anyway. Let's go to the code. Here's the classic problem in programming. Iterate through the numbers 1 through 100. If the number is divisible by 3, print fizz. If the number is divisible by 5, print buzz. If the number is divisible by 15, print…

Contents