Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## apply same change to every element in a list
- new_list = [x[10:] for x in old_list] # strip away the first 10 characters for every string in the old_list
- ## Sorting
- list.sort()
- ## Get unique elements from a list x
- unique_list = list(set(x))
- ## Append an element to a list
- list.append('New String')
- ## Extend a list
- list1.extend(list2) #the elements of list2 are added to the end of list1.
- list1 +=list2
- ## replace characters in a string (e.g. substitute x with y)
- string.replace('x', 'y')
- ##
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement