EG.
list1 = [1, 2, 3, 4]
list1[0] = None
How do I get the list to now start at 2 (make the index of 2 = list1[0]) because when I call list1[0] after doing this I get a blank output.
EG.
list1 = [1, 2, 3, 4]
list1[0] = None
How do I get the list to now start at 2 (make the index of 2 = list1[0]) because when I call list1[0] after doing this I get a blank output.
Here' how to remove the first item using slicing
>>> list1 = [1, 2, 3, 4]
>>> list1 = list1[1:]
>>> list1[0]
2
Or you can use list.pop(0)
>>> item = list1.pop(0)
>>> item
2
>>> list1[0]
3
print(list1) # [1, 2, 3, 4]
list1.pop(0)
print(list1) # [2, 3, 4]
print(list1[0])
=== Will print the following output
[1, 2, 3, 4]
[2, 3, 4]
2
Otherwise you can del(index)
or pop(index)
a item with a certain index. Del just deletes the item from the list, pop deletes the item from the list and returns it. Have a look here: Difference between del, remove, and pop on lists