基本的な質問です。私は次のコードを試しています:
class SMS_store:
def __init__(self):
self=[] #probably something is wrong here
def add_new_arrival(self,from_number,time_arrived,text_of_SMS):
self.append([False,from_number,time_arrived,text_of_SMS]) #append list to self list
self[len(self)-1]=tuple(self[len(self)-1])
def message_count(self):
return len(self)
my_inbox=SMS_store()
my_inbox.add_new_arrival('01234','9:37 AM','How are you?')
しかし、次のエラーが表示されます。
>>>
Traceback (most recent call last):
File "C:\Users\Arnob\Desktop\New Text Document.py", line 15, in <module>
my_inbox.add_new_arrival('01234','9:37 AM','How are you?')
File "C:\Users\Arnob\Desktop\New Text Document.py", line 8, in add_new_arrival
self.append([False,from_number,time_arrived,text_of_SMS]) #append list to self list
AttributeError: 'SMS_store' object has no attribute 'append'
>>>
私のコードで何が間違っていますか?