使用重复数字扩展列表的好方法是什么?

Use*_*er1 0 python

我想扩展一个数字为2450的列表,50次.有什么好办法呢?

for e in range(0,50):
    L2.extend(2450)
Run Code Online (Sandbox Code Playgroud)

Hen*_*nyH 9

这将增加245050倍. l2.extend([2450]*50)

例:

>>> l2 = []
>>> l2.extend([2450]*10)
>>> l2
[2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450]
Run Code Online (Sandbox Code Playgroud)

或者更好的是:

>>> from itertools import repeat
>>> l2 = []
>>> l2.extend(repeat(2450,10))
>>> l2
[2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450]
Run Code Online (Sandbox Code Playgroud)