这是一个简单的代码,旨在使用英语名字和姓氏列表生成全名列表:
names = """
Walter
Dave
Albert""".split()
fullnames = [(first + last) for first, last in names]
print(fullnames)
我names
只是为了这篇文章而缩小了,但我包括了 100 个名字。
输出:
Traceback (most recent call last):
File "/home/pussyslayer42069/Desktop/py/names.py", line 105, in <module>
fullnames = [(first + last) for first, last in names]
File "/home/pussyslayer42069/Desktop/py/names.py", line 105, in <listcomp>
fullnames = [(first + last) for first, last in names]
ValueError: too many values to unpack (expected 2)