Feb-11-2017, 05:09 PM
(This post was last modified: Feb-11-2017, 05:29 PM by sparkz_alot.)
I was trying this cose and I am not sure why this is not working as I am new to Python hence I am not abel to figure this out. Just trying to create a class and definitons through which I can add user and then also send them a message. Please need help on this cose not sure why I am getting errors like ,
Error:"SyntaxError: multiple statements found while compiling a single statement"
"Traceback (most recent call last):
File "<pyshell#36>", line 1, in <module>
obj.add_user("justin", 123.32)
AttributeError: 'MessageUser' object has no attribute 'add_user'"
Traceback (most recent call last):
File "<pyshell#38>", line 1, in <module>
obj.get_details()
AttributeError: 'MessageUser' object has no attribute 'get_details'
Here is the Code,import datetime class MessageUser(): user_details=[] messages=[] base_message="""Hi {name}! Thank you for the purchase on {date}. We hope you are exited about using it. Just as a reminder the purchase total was ${total}. Have a great one! Team CFE """ def add_user(self, name, amount): name=name[0].upper()+name[1:].lower() amount="%.2f" %(amount) detail={ "name": name, "amount": amount, } today=datetime.date.today() date_text='{today.month}/{today.day}/{today.year}'.format(today=today) detail['date']=date_text self.user_details.append(detail) def get_details(self): return self.user_details def make_messages(self): if len(self.user_details)>0: for detail in self.get_details(): name=detail["name"] amount=["amount"] date=detail[date] message=self.base_message new_msg=unf_mesage.format( name=name, amount=amount, date=date ) self.messages.append(new_msg) return self.messages return[] obj=MessageUser() obj.add_user("justin",123.32) obj.add_user("john",94.32) obj.get_details()Really need help....