Skip to content

Instantly share code, notes, and snippets.

@Omig12
Last active March 17, 2017 19:45
Show Gist options
  • Save Omig12/e4ff3f9d0f940fbef082914e2add020b to your computer and use it in GitHub Desktop.
Save Omig12/e4ff3f9d0f940fbef082914e2add020b to your computer and use it in GitHub Desktop.

Revisions

  1. Omig12 revised this gist Mar 17, 2017. No changes.
  2. Omig12 revised this gist Mar 17, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions reverse_list_substring.py
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,8 @@
    #!/usr/bin/env python3

    # l = Full list or string to be reversed.
    # start = Index where the sub-string to be reversed starts
    # end = Index where the sub-string to be reversed ends

    def rev_sub(l, start, end):
    return l[0:start]+l[start:end+1][::-1]+l[end+1:]
  3. Omig12 revised this gist Mar 17, 2017. No changes.
  4. Omig12 created this gist Mar 16, 2017.
    2 changes: 2 additions & 0 deletions reverse_list_substring.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    def rev_sub(l, start, end):
    return l[0:start]+l[start:end+1][::-1]+l[end+1:]