Python language basics 11: while loops

Exercises in .NET with Andras Nemes

Introduction

In the previous post in this series we looked at if statements in Python. We saw how to set up conditions and tweak our actions accordingly. An if-block is only carried out if the boolean expression results in true.

However, what if we want to carry out an action as long as some condition is true and stop as soon as the condition is false? Consider the following sentences:

If the weather is nice then we’ll play football.

vs.

While the weather is nice we’ll be playing football.

View original post 288 more words

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.