1range(4) # [0, 1, 2, 3] 0 through 4, excluding 4
2range(1, 4) # [1, 2, 3] 1 through 4, excluding 4
3range(1, 10, 2) # [1, 3, 5, 7, 9] 1 through 10, counting by 2s
4
1# range(start, stop, step)
2 # start = (can be ommitted) index to begin at (INCLUSIVE)
3 # stop = generate numbers up to, but not including this number (EXCLUSIVE)
4 # step = (can be omitted) difference between each number in the sequence
5
6# idx: 0 1 2 3 4
7# arr: 19 5 3 22 13
8
9arr = [19,5,3,22,13]
10
11# range(stop)
12for i in range(len(arr)):
13 print(arr[i]) # prints: 19, 5, 3, 22, 13
14
15# range(start, stop)
16for i in range(2, len(arr)):
17 print(arr[i]) # prints: 3, 22, 13
18
19# range(start, stop, step)
20for i in range(0, len(arr), 2):
21 print(arr[i]) # prints: 19, 3, 13
22
23# reverse:
24for i in range(len(arr)-1, -1, -1):
25 print(arr[i])
1range(start, stop, step)
2
3x = range(0,6)
4for n in x:
5print(n)
6>0
7>1
8>2
9>3
10>4
11>5
1#can be used a sequence of numbers
2x = range(6)
3print(x)
4#Outputs 0 1 2 3 4 5
5
6for i in range(start,finish ,step)
7#gives range of numbers
8#start is optional default is 0
9#finish needed specifying when to stop
10#step is incremetntaition of jump also optional