电流输出:
从前有一只狗狂吠 吠叫 曾是 A 名字
所需输出:
从前有一只狗狂吠 吠叫是一个名字
代码:
list1 = ['There', 'once', 'was', 'a', 'dog', 'who', 'barked']
list2 = ['name']
print(' '.join(list1))
print(list1[-1]), print(list1[2]), print(list1[3]), print(list2[0])
# There once was a dog who barked
# barked was a dog name
# There once was a dog who barked
# name a dog barked once was
`
I tried using the join list function, but that did not work very well. Looking for recommendations thank you
肯定有一些重复的地方,但你需要事先连接列表:
list1 = ['There', 'once', 'was', 'a', 'dog', 'who', 'barked']
list2 = ['name']
output = " ".join(list1 + list2)
print(output)
哪个产量
There once was a dog who barked name