Recently I was learning python,and I want to use the function that is opposite of append() function.How can I use the function insert an element in the first position of the list.Thank you!
            Asked
            
        
        
            Active
            
        
            Viewed 3.7k times
        
    2
            
            
        - 
                    1Is a function that inserts an element in the first position of a list really the opposite of `list.append()`? Wouldn't the opposite be something like, "remove the last element from a list and return it"? The more clearly you ask your question the more likely you are to get a good answer. – ChrisGPT was on strike Apr 25 '16 at 15:52
1 Answers
15
            Prepend doesn't exist, but you can simply use the insert method:
list.insert(0, element)
 
    
    
        Pierre Barre
        
- 2,174
- 1
- 11
- 23
