Basic Python Functions
Rock those LeetCode easies with these basic Python functions 😛 Lists list.insert(<index>, <elem>) list.remove(<elem>) #removes first matching occurrence of element list.append(elem) list.extend(<another list>) #concatenates two lists (or a list and any iterable) list.sort() #check below to see more on sorting list.reverse() #this acts in place, returns none list.pop(<index>) x = list.pop(index) # returns popped value x = list.index(index) x = list.count(elem) Check if Val in List <elem> in list Clone a List x = list(<list>) Lists & Tuples x = tuple(<list>) y = list(<tuple>) String/List Manipulation Split String by Delimiter s tring.split(<separator, default whitespace>) txt = “hello how are you” x = txt.split() # this will output: [‘hello’, ‘how’, ‘are’, ‘you’] Split String by Character list(<string>) list(nice) # this will output [‘n’,’i’,’c’,’e’] Join a List into a String separator.join(<iterable>) numL...