我怎么放!在列表中的每个字符之后
listOne = ["hello","world"]
我如何把它变成:
["h!e!l!l!o","w!o!r!l!d"]
试图:
def turn(List):
return [i for i in (list(lambda x: "%s!" % x,listOne))]
turn(listOne)
回报:
['hello!',"world!"]
除了:
def turn(List):
x = ""
for word in words:
for letter in word:
x += "%s!" % letter
return x
turn(listOne)
我不是做这样的事情的忠实粉丝,但我确实意识到这可能比我正在尝试做的更pythonic,那就是让它尽可能少的行。这可能吗?