gpt4 book ai didi

python - 如何在 python 中格式化列表输出

转载 作者:行者123 更新时间:2023-11-28 22:44:16 30 4
gpt4 key购买 nike

我正在尝试格式化索引和列表的输出:

[6]
[7]
[8]
[9]
The answers should be:
['b', 'c', 'a', 'c']`

更像这样:

[6]  b   
[7] c
[8] a
[9] c

这是代码片段:

print( "Here are the questions the you got wrong: ")
for i in range (0, 10):
if q[i] != answers[i]:
print ( [i+1],)
else:
("You got all of the questions correct, Good Job. ")
print("The answers should be: ")
print(wrongList)

最佳答案

你没有收集到 wrongList 但它很容易做到:

print("The answers should be: ")
for i in range (0, 10):
if q[i] != answers[i]:
print (q[i], answers[i])

关于python - 如何在 python 中格式化列表输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29722663/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com