给定一个数字n和另外两个值,请编写一个函数,构造一个长度为n的列表,并交替使用这两个值填充到列表中。
【示例】
输入:5, True, False
输出:[True, False, True, False, True]
解释:列表会包含5个元素,从True开始填充,然后是False,以此类推。
题目难度:简单
题目来源:codewars- Length and two values.
def solution(n: int, v1, v2)-> list:
# your code here
assert solution(5, True, False) == [True, False, True, False, True]
assert solution(10, "blue", "red") == ["blue", "red", "blue", "red", "blue", "red", "blue", "red", "blue", "red"]
assert solution(0, "one", "two") == []