gpt4 book ai didi

python - l.append[i],对象不可下标?

转载 作者:太空狗 更新时间:2023-10-30 00:23:40 28 4
gpt4 key购买 nike

<分区>

当我这样做时:

l = []
for i in range(10):
if i%3 == 0 or i%5 == 0:
l.append[i]
print sum(l)

我明白了

Traceback (most recent call last):
File "PE1.py", line 4, in <module>
l.append[i]
TypeError: 'builtin_function_or_method' object is not subscriptable

真的没有办法追加所有通过条件的 i 吗?

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