Can Someone Explain This Statement? Lpadded = Win // 2 * [-1] + L + Win // 2 * [-1]
Given that l is a list of integers and win is an integer, the following code produces a list lpadded: lpadded = win // 2 * [-1] + l + win // 2 * [-1] In lpadded -1 is padded to th
Solution 1:
In Python, you can “multiply” a list by an integer to build a list of repeated elements.
>>> [42] * 4[42, 42, 42, 42]
>>> ['hello', 'world'] * 3['hello', 'world', 'hello', 'world', 'hello', 'world']
So the expression win // 2 * [-1]
creates a list
object containing win // 2
copies of the number -1.
Post a Comment for "Can Someone Explain This Statement? Lpadded = Win // 2 * [-1] + L + Win // 2 * [-1]"