【发布时间】:2014-10-29 22:04:20
【问题描述】:
这只是我的代码的一部分,但我在对齐它时遇到了麻烦 我希望它以以下方式打印输出:
N a m e
1 2 3 4
现在它做了这样的事情:
['J', 'o', 'h', 'n', ' ', 'S', 'm', 'i', 't', 'h']
['[', '1', ',', ' ', '6', ',', ' ', '8', ',', ' ', '5', ',', ' ', '1', ',', ' ', '4', ',', ' ', '9', ',', ' ', '2', ',', ' ', '8', ']']
提醒一下,我还是 python 新手哈哈
print("Your name and numeric value is:")
fullname = first_name + " " + last_name
print(list(fullname))
name = first_name + last_name
name = str.lower(name)
output = []
for letter in name:
number = (ord(letter) - 97)%9 + 1
output.append(number)
print(list(str(output)))
【问题讨论】:
-
那是什么问题?
-
@Kasra 我想将每个字母对齐到列中,以便第一行和第二行是统一的
-
你能添加更清晰的输入和期望输出吗?
-
你能告诉我们现在正在打印什么吗?
-
我对其进行了编辑以显示前任。输出