Python Forum
Need Help to understand class
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need Help to understand class
#3
(Jun-05-2018, 08:50 AM)Roshan Wrote: what is wrong with me ?
:-) There is nothing wrong with you, I hope... There is problem that you cannot add/concatinate str and int.
Please, always post the entire traceback that you get. Take a time to read What to include in a post.
That said it's better to get use of more advanced string formatting features
def myfunc(self):
    print("Hello my name is {}".format(self.name))
    print("My age is {}".format(self.age))
if you are on python 3.6+ you can even use the f-strings
def myfunc(self):
    print(f"Hello my name is {self.name}.")
    print(f"My age is {self.age}.")
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Need Help to understand class - by Roshan - Jun-05-2018, 08:50 AM
RE: Need Help to understand class - by j.crater - Jun-05-2018, 08:56 AM
RE: Need Help to understand class - by buran - Jun-05-2018, 08:57 AM
RE: Need Help to understand class - by DeaD_EyE - Jun-05-2018, 09:01 AM
RE: Need Help to understand class - by Roshan - Jun-05-2018, 09:05 AM
RE: Need Help to understand class - by buran - Jun-05-2018, 09:07 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020