[英]Print columns side by side in python
When applying this code: (for example)应用此代码时:(例如)
x = ["Apple\napple", "Orange\norange", "Banana\nbanana"]
for i in x:
print(i, end = " ")
The result is:结果是:
Apple
apple Orange
orange Banana
banana
But I need a way to make it like this:但我需要一种方法来使它像这样:
Apple Orange Banana
apple orange banana
Try this code below试试下面的代码
x = ["Apple\napple", "Orange\norange", "Banana\nbanana"]
y = [x[i].split() for i in range(len(x))]
print(f'{y[0][0]} {y[1][0]} {y[2][0]}\n{y[0][1]} {y[1][1]} {y[2][1]}')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.