import sys
sys.version'3.13.3 (main, Apr 8 2025, 13:54:08) [Clang 16.0.0 (clang-1600.0.26.6)]'
import sys
sys.version'3.13.3 (main, Apr 8 2025, 13:54:08) [Clang 16.0.0 (clang-1600.0.26.6)]'
if - elif - elsea = 4Conditionals do not require parentheses:
if a < 10:
print("hello")hello
But they work with them just the same:
if (a < 10):
print("hey")hey
x1 = 9if x1 > 10:
print("x1 is greater than 10")
elif 5 < x1 <= 10:
print("x1 is between 5 and 10")
else:
print("x1 is not very big") x1 is between 5 and 10
for loopsfor i in range(4):
print("Working on Feature " + str(i))Working on Feature 0
Working on Feature 1
Working on Feature 2
Working on Feature 3
enumerate()enumerate(iterable, start=0) outputs pairs of an index (starting at start) and an item from iterable
a = ['one', 'two', 'three', 'four']for it in enumerate(a):
print(it)(0, 'one')
(1, 'two')
(2, 'three')
(3, 'four')
for i, el in enumerate(a, start=1):
print("Item number ", i, ": ", el, sep = '')Item number 1: one
Item number 2: two
Item number 3: three
Item number 4: four
while loopsx = 18
while x > 12:
x -= 1
print(x)17
16
15
14
13
12