我有这段代码可以将两个列表转换为垂直列并打印出来:
team1 = ['Vàlentine', 'Consus', 'Never Casual ', 'NucIear', 'Daltwon']
team2 = ['The Aviator', 'Iley', 'Nisquick', 'Dragoon', 'WAACK']
for t1, t2 in zip(team1, team2):
print('%-20s %s' % (t1, t2))
如何调整此代码以添加第三个列表,例如 team3 = ['...']
?
输出:
Vàlentine The Aviator <team3 here>
Consus Iley
Never Casual Nisquick
NucIear Dragoon
Daltwon WAACK
使用:
for t1, t2, t3 in zip(team1, team2, team3):
print('%-20s %s' % str(t1, t2, t3))
好像不行。
最佳答案
像这样
team1 = ['Vàlentine', 'Consus', 'Never Casual ', 'NucIear', 'Daltwon']
team2 = ['The Aviator', 'Iley', 'Nisquick', 'Dragoon', 'WAACK']
team3 = ['Ronaldo', 'Messi', 'Zidane', 'Me', 'Raul']
for t1, t2, t3 in zip(team1, team2, team3):
print('%-20s %-20s %s' % (t1, t2, t3))
关于python - 如何修改此代码以用于多个列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57173818/