List Built-In Methods
The data type “List” has several built-in methods.
s = ['h','e','l','l','o'] #create a list
s.append('d') #append to end of list
len(s) #number of items in list
s.pop(2) #delete an item in the middle
s.sort() #sorting the list
s.reverse() #reversing the list
s.extend(['w','o']) #grow list
s.insert(1,2) #insert into list
s.remove('d') #remove first item in list with value e
s.pop() #remove last item in the list
s.pop(1) #remove indexed value from list
s.count('o') #search list and return number of instances found
s = range(0,10) #create a list over range
s = range(0,10,2) #create a list over range with start index and increment
Recommended Python Training
Course: Python 3 For Beginners
Over 15 hours of video content with guided instruction for beginners. Learn how to create real world applications and master the basics.