Ask coding questions

← Back to all posts
1
I cant find the error

I cant find the error in my code... It just says invalid syntax, but i cant find whats wrong.... https://im-boi2.thespeakinglava.repl.run

Answered by
ArchieMaclean (490)
[earned 5 cycles]
View Answer
Commentshotnewtop
1

f strings only support variables - you are trying to use a function (random.choice(responses)) inside (on line 45). This doesn't work. An example fix is:

async def _8BALL(ctx, *, question):
  responses = [
    # ...
  ]
  response = random.choice(responses)
  await ctx.send(f'Question: {question}\nAnswer: {response}')

Also, make sure that the await is on the same indentation level as the rest of the function (like above).

Please mark this as the answer if it solved your problem :)

1
1

@TheSpeakingLava On line 45, you had

  await ctx.send(f'Question: {question}\nAnswer: {random.choice(responses)}')

but having random.choice in there doesn't work. So instead you can do

response = random.choice(responses)
await ctx.send(f'Question: {question}\nAnswer: {response}')
1

@ArchieMaclean Do u have any idea of how I can make it run 24/7 without interacting with it?