Discord.py - SyntaxError f-string: empty expression not allowed

Jakaboi picture Jakaboi · Jun 14, 2019 · Viewed 8.1k times · Source

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

Answer

CrazySqueak picture CrazySqueak · Jun 14, 2019

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.