8

I'm getting a SyntaxError: f-string: empty expression not allowed I'm not sure (at all) what this means

I've tried moving around the code & looked online but I've got no different results

The code is:

@client.command()
async def load(ctx, extension):
 client.load_extension(f'cogs.{extension}')

 await ctx.send(f"Loaded the {} module!".format(extension))

It's for cogs & I'm sure I've got everything else right, I'm not sure though

If anyone knows what to do then please tell me, thx

Jakaboi
  • 281
  • 2
  • 10
  • 20

2 Answers2

21

The problem is the empty {} in the f-string. F-strings require a variable name between the braces. The line with the string should be:

await ctx.send(f"Loaded the {extension} module!")

Or

await ctx.send("Loaded the {} module!".format(extension))

Hope this helps.

CrazySqueak
  • 584
  • 4
  • 8
8

If you want to keep your code structure the way it is, you can also do like this:

await ctx.send(f"Loaded the {{}} module!".format(extension))
herickmota
  • 457
  • 6
  • 13