【发布时间】:2021-07-06 06:10:33
【问题描述】:
我是这样做的。我相信还有很多其他方法可以更专业地做到这一点。 不要介意我的代码,我两周前开始使用 python,它是我的第一语言。
"""Grab the first letters of the names:"""
names = 'Schmo', 'Nate', 'Wonderboy'
first_lett = []
first_lett.append(names[0][0])
first_lett.append(names[1][0])
first_lett.append(names[2][0])
print(first_lett)
【问题讨论】:
-
如果您的代码按预期工作,并且您正在寻找有关改进它的建议,那么您的问题可能会在codereview.stackexchange.com 上更热门
标签: python string append character