repl.it
@JosephLooney/

Slicing lists

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#slicing lists will give a part of a list
myList = [1,2,3,4,5,6,7,8,9,10]

print(myList)
print(myList[0:3])
print(myList[1:4])

print(max(myList))
print(min(myList))

print (myList[:4])# < 4th index
print (myList[4:])# >= 4

print (myList[1:4:2])
print (myList[0::2])
print (myList[0:len(myList):2])

print(sum(myList))
Fetching token
?