In order to write my code more elegantly, I would like to append an item to a list and return the index of the newly created item. For example,
a_idx = append(lst, "a")
b_idx = append(lst, "b")
...
To achieve this functionality I wrote a simple append function:
def append(lst, item):
lst.append(item)
return len(lst) - 1
Is there something built-in in Python that is similar to my append
function?