小编Log*_*gan的帖子

使列表中的字符串大写 - Python 3

我正在学习python,并通过一个实际示例遇到了一个我似乎无法找到解决方案的问题。我使用以下代码得到的错误是 'list' object has to attribute 'upper'.

def to_upper(oldList):
    newList = []
    newList.append(oldList.upper())

words = ['stone', 'cloud', 'dream', 'sky']
words2 = (to_upper(words))
print (words2)
Run Code Online (Sandbox Code Playgroud)

python-3.x uppercase

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

python-3.x ×1

uppercase ×1