emptylist = [] #help(list.append) # mandatory arguments: 1 # type arguments: ''' explanation: ''' # example with explanation above emptylist.append(2) print emptylist emptylist.append(3) print emptylist emptylist.append(2) print emptylist #help(list.count) # mandatory arguments: 1 # type arguments: ''' explanation: ''' # example with explanation above print emptylist.count(2) print emptylist.count(3) help(list.index) # mandatory arguments: 1 # type arguments: ''' explanation: Only for the first occuring item. ''' # example #Here it shows us that '3' occurs at index 1 print emptylist.index(3) #Here it shows us that '2' occurs at index 0 (and not 2) print emptylist.index(2) help(list.insert) # mandatory arguments: 2 # type arguments: the first argument has to be int, the second can be anything that can be added in a list. ''' explanation: .insert does not return anything, but changes the current list by inserting an element before an index specified in the first argument of the method. ''' # example # Here '8' gets added to the list before the 6th index (so at the end) emptylist.insert(6,8) print emptylist # Here '8' gets added to the list before the 6th index emptylist.insert(2,8) print emptylist help(list.pop) # mandatory arguments: 0 # type arguments: - ''' explanation: .pop changes the current list by deleting the last element of a list, and then returns this deleted element. With optional arguments you can specify the index of an item you would like to see removed from the list. ''' # example # This removes the last '8' in the list print emptylist.pop() # The changed list without '8' print emptylist # This removes the first '2' in the list print emptylist.pop(0) # The changed list without '2' print emptylist
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question