import string
def make_lists(a):
characters = string.uppercase # Relace this with your custom char set if necessary
my_list = [[c] * n for n, c in zip(a, characters)]
return my_list
输出:
In [11]: a = [4, 2, 3]
In [12]: play.make_lists(a)
Out[12]: [['A', 'A', 'A', 'A'], ['B', 'B'], ['C', 'C', 'C']]
顺便说一句,不要调用变量
list
,它是一个内置函数的名称。你知道吗只是另一个解决方案:
的内容播放.py你知道吗
输出:
相关问题 更多 >
编程相关推荐