# Syntax - range(start, stop, step) - you must use integers, floats cannot be used
for i in range(3):
print(i)
# output - automatically taken start = 0 and step = 1, we have given stop = 3 (excluding 3)
for i in range(0, 4):
print(i)
# output - We have given start = 0 and stop = 4 (excluding 4), automatically taken step =1
for i in range(0, 5, 2):
print(i)
# output - We have given start = 0, stop = 5 (excluding 5), step = 2
for i in range(0, -4, -1):
print(i)
# output - We can go even backwards and also to negative numbers
## ignoring a value
a, _, b = (1, 2, 3) # a = 1, b = 3
print(a, b)
## ignoring multiple values
## *(variable) used to assign multiple value to a variable as list while unpacking
## it's called "Extended Unpacking", only available in Python 3.x
a, *_, b = (7, 6, 5, 4, 3, 2, 1)
print(a, b)
When you are not interested in some values returned by a function
we use underscore in place of variable name .
Basically we don't care about the iterator value, just that it
should run some specific number of times.
for variable in range (69): # Runs the code below 69 times, sets the var "variable" to the index
print(variable) # Prints the var "variable" (every time the number will be bigger)
print("Done") # This will not get sent 69 times.