小编Joe*_*_49的帖子

Python 错误:“列表对象没有属性“.upper”

我目前正在尝试在 python 中编写一个代码,如果您对它的回复在可能的答案列表中,它将回复您。程序示例如下。

def responce():
    greetings = ["Hello","Hi","Nice to see you!","Greetings","How's it going?","How are you doing?","What's new?","How's your day going?","Hey!"]
    print("\n")
    reply = input(": ")
    lenrep = len(reply)
    tempstore = []
    for i in range(0,lenrep):
        tempstore.append(i)
        z = 0
        while z < 9:
            tempgreet = greetings[z]
            if tempstore.upper() == tempgreet.upper():
                reply = ""
                tempstore = []
                temprandno = random.randint(0,2)
                addon = ["what do you want to know?", "what do you want to talk about?", " "]
                addontext = addon[temprandno]
                text(greet(), …
Run Code Online (Sandbox Code Playgroud)

python python-3.x

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

标签 统计

python ×1

python-3.x ×1