#πŸ”’ Help with Method in Class

29 messages Β· Page 1 of 1 (latest)

frail blaze
#

just learning python like 3 days ago and was messing around, but i dont get why this doesnt work

storm currentBOT
#

@frail blaze

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

frail blaze
#

idk how to post the code im on mobile

misty dawn
#

you know how you can't add a number to a string?

#

!e 'a'+2

storm currentBOT
#

@misty dawn :x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     'a'+2
004 |     ~~~^~
005 | TypeError: can only concatenate str (not "int") to str
misty dawn
#

same thing here but instead of a number

#

you are trying to add your own class to the string

#

with self

frail blaze
#

hmm

#

do u mean in the method

wary merlin
#

yeah you probably want self.name there instead

frail blaze
#

ohhh yeah

misty dawn
frail blaze
#

yeah i was able to do it before but i forgot

#

i always forget like 1 thing

#

lol

#

thanks

misty dawn
#

np

frail blaze
#

is this good for 3 days into learning πŸ™πŸΌπŸ’€

#

i feel like im slow when it comes to this lmoshh

misty dawn
#

learning classes 3 days into python is really good!

#

personally I didn't learn class stuff until a few weeks into python

frail blaze
#

yeah my younger brother knows lua and he told me to learn this

#

like i just ask him what to learn and he tells me like learn oop

#

and he said tables too

frail blaze
storm currentBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.