Skip to content
← Back to Community
SYNTAX ERROR!!!!!!!!!!!
Profile icon
Abesthebot

Screenshot (95)

I have no clue what's the syntax error the tutorial matches my code. Here's the screenshot of the tutorial.
Screenshot (96)

Answered by maxina [earned 5 cycles]
View Answer
Voters
Profile icon
Zyru
Profile icon
KIDS-MATHS-AND
Profile icon
MANSI3851
Profile icon
qvrtzk
Profile icon
Abesthebot
Comments
hotnewtop
Profile icon
maxina

Error:
You aren't closing your print statement.
Correct code:
import discord
import os

client = discord.Client()

@client.event
async def on_ready():
print('We have logged in as {0.user})
'.format(client))

@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')

client.run(os.getenv('TOKEN'))
Profile icon
Abesthebot

THANK YOU SO [email protected]

Profile icon
RYANTADIPARTHI

Solution

This is because you aren't closing your quotes. You have a print statement, but you aren't closing it.

import discord import os client = discord.Client() @client.event async def on_ready(): print('We have logged in as {0.user}'.format(client)) @client.event async def on_message(message): if message.author == client.user: return if message.content.startswith('$hello'): await message.channel.send('Hello!') client.run(os.getenv('TOKEN'))

like that.
That should work

Profile icon
Abesthebot

THANK YOU SO [email protected]

Profile icon
alanchen12

Basically the issue is that you never closed the quotes. The reason why this is is because the person who made the tutorial had text wrapping since the console was expanded or the screen wasn't that big. you can solve it by putting the end quote on the previous line.

Profile icon
Abesthebot

@alanchen12 THANK YOU SO MUch I’m in my early teens so I didn’t really understand much but would you mind showing an example of putting the end quote on the previous line?

Profile icon
alanchen12

Instead of

print('We have logged in as {0.user} '.format(client))

use

print('We have logged in as {0.user}'.format(client))

@Abesthebot

Profile icon
Abesthebot

THANK YOU SO MUCH @alanchen12

Profile icon
19wintersp

The indent on lines 11-18 are unnecessary: it shouldn't have a tab in front. Also, line 9 should be on the same line as line 8, it just looks like that because the text is wrapping. Here's a fixed version

The reason you are getting this error is because Python is having an issue with the missing quote and closing bracket on line 8.

Profile icon
Abesthebot

THANK YOU GUYS SO [email protected]