Python - set list range to a specific value

前端 未结 3 1978
别那么骄傲
别那么骄傲 2020-12-10 14:06

I need to set a subset of a list to a specific value based on a tuple with bounds (start,end).

Currently I\'m doing this:

indexes = rang         


        
3条回答
  •  误落风尘
    2020-12-10 14:40

    >>> L = list("qwerty")
    >>> L
    ['q', 'w', 'e', 'r', 't', 'y']
    >>> L[2:4] = ["foo"] * (4-2)
    >>> L
    ['q', 'w', 'foo', 'foo', 't', 'y']
    

提交回复
热议问题