#๐Ÿ”’ TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

38 messages ยท Page 1 of 1 (latest)

astral falconBOT
#

@rapid flax

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.

rapid flax
#

My whole message was deleted becuase it was to long I've got a python script that I was given from another program and I've got the error in the title

#

and this is the whole error I'm given
error: Traceback (most recent call last):
File "<string>", line 200, in <module>
File "<string>", line 60, in CustomInitializer
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

#

I've tried looking up on google the error and the main fix was to look through the prints and fixing the syntax by adding a % and I couldnt find anything that fit that

raven pawn
#

!e None + "abc"

astral falconBOT
#

@raven pawn :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 |     None + "abc"
004 |     ~~~~~^~~~~~~
005 | TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
raven pawn
#

Is your paste accurate in the indentation? And by that I mean "are you using single spaces for indentation"?

rapid flax
#

This is what it actually looks like,

#

I'm not sure why its not right in the paste

raven pawn
#

Well you have a mix in that screenshot too

rapid flax
#

I see that now

raven pawn
#

Should be 4 spaces per indentation level

#

which if you set up correctly in your IDE, can be entered using the Tab button

rapid flax
#

Will the indention spacing being off cause that error as well?

raven pawn
#

It shouldn't be, no

rapid flax
#

I'll go through and fix it now tho

#

Is this what the issue could be?

raven pawn
#

Issue is that original_macros can probably sometimes be None

#

(What I gather from the error msg)

rapid flax
#

so it should be original_macros % ";IDA=1")?

raven pawn
#

No

rapid flax
#

I'm extremely new to python so I've very confused in all of this LOL

raven pawn
#

Unless it is a string formatted to accept that

#

But I can tell you that it definitely is not the case

raven pawn
#

That is your issue

#

It's not a string in the error

#

No amount of "maybe I'll do this string operation instead" will change the value of it

#

Because it's not a string

#

Do you know about None?

rapid flax
#

A little bit yea, I'm trying to do some googling to see if I can get more info tho

raven pawn
#

it is a singleton, used to represent an "absent" value

#

A function by default returns None if no return statement is reached. It will also return None if a blank return is reached

rapid flax
#

so im getting the error just because i dont have a return statement for original_macros?

astral falconBOT
#
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.