Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save RyanMillerC/ab8fb71a7b61d12c4e5c643eb4932dab to your computer and use it in GitHub Desktop.

Select an option

Save RyanMillerC/ab8fb71a7b61d12c4e5c643eb4932dab to your computer and use it in GitHub Desktop.

Revisions

  1. Ryan Miller renamed this gist Jul 30, 2018. 1 changed file with 0 additions and 0 deletions.
  2. Ryan Miller created this gist Jul 30, 2018.
    17 changes: 17 additions & 0 deletions Better Loop Pattern for Parallel Lists
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    L = ['value', 'value2', 'value3']
    L2 = ['value', 'value2', 'value3']

    # Old-Old way
    for index in range(len(L)):
    item = L[index]
    item2 = L2[index]
    print(item, item2)

    # Old way
    for index, item in enumerate(L):
    item2 = L2[index]
    print(item, item2)

    # New way
    for item, item2 in zip(L, L2):
    print(item, item2)