Indentation Error (Anyone see it?)

if msg.startswith(";del"):
  encouragements = [   ]
  if "encouragements" in db.keys():
      index = int(msg.split(";del",1)[1])
      encouragements = db["encouragements"]

Does anyone see the error? It is supposedly after the closing bracket on encouragements

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Ok. Sorry!

Can you see any errors though?

Sorry, I’m not a Python guy, but did you switch from indenting 2 to indenting 4? I thought you had to be consistent?

That might just work…

But then await would be outside the function!

That’s only looking at it in one direction.

What is your indentation?

Why is the indentation from line 1 to line 2 an indentation of 2, but then on the next line it jumps to 4?

Well I’m not really a fan of building bots…
But if I’m not wrong :

Be careful, both index, encouragements and also await message channel.send are “inside” the conditional if
Hope this helps.

Thanks! Can you help with this: Type Error: Concatenate

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.