June 2017
Beginner to intermediate
274 pages
6h 49m
English
Python has several flow control statements that will be familiar to people who know another language in the C family. For example, Python has loops and if, elif, and else branches (shown in the following code example):
selector = 5
if selector < 3:
print("less than three")
elif selector < 6:
print("less than six")
else:
print("six or more")
while selector > 0"
print('selector is {}' .format(selector))
selector -=1
for x in ['a', 'b', 'c', 'd']:
print(x)
for x in range(5):
print(x)
Python also has a for loop statement, but it's not like the for loops in C, C++, or Java. Instead of counting through numbers, the for loop iterates through the values. If we actually want to count through numbers with a for loop, that's ...
Read now
Unlock full access