DEV Community

Cover image for Essential Python 3 code for lists

Essential Python 3 code for lists

edA‑qa mort‑ora‑y on March 07, 2019

Python 3 examples for all of the things I listed in my previous article. Essential code for lists and vecto...
Collapse
 
yorodm profile image
Yoandy Rodriguez Martinez

I use enumerate a lot so:

for index, element in enumerate(my_list):
    # Do whatever
Collapse
 
detunized profile image
Dmitry Yakimenko • Edited
mylist.append( "abc" )
mylist.insert(0, "def")

Why do you have inconsistent formatting? Is there some rule that I cannot figure out or simply an oversight?

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

Hopefully I have them all fixed now. I was copy-and-pasting back-and-forth to the interactive editor, thus messed up the style sometimes.