Re: explain slice assignment to newb

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sean DiZazzo

    Re: explain slice assignment to newb

    On Sep 20, 2:20 pm, Andrew <aet...@gmail.c omwrote:
    please explain this behavior to a newb:
    >
    >a = [1,2,3,4]
    >b = ["a","b","c" ,"d"]
    >a
    [1, 2, 3, 4]
    >b
    >
    ['a', 'b', 'c', 'd']
    >
    >a[0:2]
    [1, 2]
    >a
    [1, 2, 3, 4]
    >b[2:4]
    ['c', 'd']
    >a[0:2] = b[0:2]
    >b[2:4] = a[2:4]
    >a
    ['a', 'b', 3, 4]
    >b
    ['a', 'b', 3, 4]
    What else would you expect to happen?
Working...