現在、Pythonでコードをプログラムしようとしていますが、返答が可能な回答のリストにある場合に返信します。 。Pythonエラー: "リストオブジェクトに属性がありません" .upper "
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(), + " " + addontext)
z += 1
if i == " ":
tempstore = []
今、私の質問は、なぜそれがエラー
AttributeError: list object has no attribute 'upper'
を思い付くんされており、それを動作させるために私のプログラムを修正する方法はありますか?
いかなるいただき、ありがとうございます応答。
の
'tempstore'はリストであり、' upper() 'メソッドはありません。リスト内の単語を探すことを意味しましたか? – MooingRawr
リストにはメソッド 'upper()'がありません: 'tempstore'はそのリストです。それは整数のリストなので、それについて大文字にしたいものは不明です。 – Evert
はい私はリストMooingRawrの単語を探すことを意味した –