我在其中使用了具有函数的循环以获取名称和名称。我已经编码并能够打印以下内容(这些名称均以新行启动):
Micheal
John
Mick
Neil
Phill
Billy
Jackson
Lennon
Jagger
Young
Collins
Joel
我现在如何制作程序,以便它像这样打印(也在新行上的所有名称,另一行上的姓氏,杰克逊在第2行上):
Micheal
Jackson
John
Lennon
Mick
Jagger
Neil
Young
Phill
Collins
Billy
Joel
我不确定我明白你的问题,但是,如果我这样做,您正在要求这样的东西:
names = ["Michael", "John"]
surnames=["Jackson" ,"Lennon"]
for i, j in names, surnames:
print i
print j
您也可以有一个带有相应名字和姓氏的字典。