How to pop the first element of a list in Python

3 Answers

0 votes
my_list = [4, 63, 9, 2, 1, 7]

first_element = my_list.pop(0)

print(my_list)       


'''
run:

[63, 9, 2, 1, 7]

'''

 



answered May 2 by avibootz
0 votes
my_list = [4, 63, 9, 2, 1, 7]

del my_list[0]

print(my_list)       



'''
run:

[63, 9, 2, 1, 7]

'''

 



answered May 2 by avibootz
0 votes
my_list = [4, 63, 9, 2, 1, 7]

my_list = my_list[1:]

print(my_list)       



'''
run:

[63, 9, 2, 1, 7]

'''

 



answered May 2 by avibootz
...