1
L = list(range(1,99,2))
s = L[:len(L)//2]#I want to get the first half of this list
print(s)

what does the colon mean in the 2 lines?

if I write the:, it prints [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21,23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47], and it's exactly what I need.

if not, it only prints 49

cwcauc
  • 21
  • 3

0 Answers0