gpt4 book ai didi

python - 在列表 [Python] 上使用追加时出现 NameError

转载 作者:太空宇宙 更新时间:2023-11-04 08:05:52 24 4
gpt4 key购买 nike

<分区>

我正在尝试使用 Python 2.7.10 制作一个简单的刽子手游戏。但是,当我尝试为列表中单词中的每个字母附加“_”时。它抛出:

Traceback (most recent call last):
File "C:\Users\Janek\Dropbox\python\vjesalo.py", line 82, in <module>
append.wordlen(olo)
NameError: name 'append' is not defined

不知道为什么会这样,因为如果我在 python 终端中运行

list = []
list.append("Bla bla bla")

一切正常

这是我的代码:

from sys import exit
from time import sleep

word = raw_input("Enter a word: ")

if word.isalpha() == True:
word.lower()
else:
print "Invalid word!"
sleep(3)
exit()

wordlen = []
for i in range(len(word)):
append.wordlen("_")

print wordlen

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