Home > OS >  SyntaxError: invalid syntax, I don't know how to fix this code. What's wrong with it? And
SyntaxError: invalid syntax, I don't know how to fix this code. What's wrong with it? And

Time:10-28

The part of the code that produced the error

def modinverse(a,26):
  
  for x in range(0,26):
    if(((a&)*(b&))& == 1):
      return x
  return -1

print(modinverse(a,26))

Here is the error I got

  File "main.py", line 51
    def modinverse(a,26):
                     ^
SyntaxError: invalid syntax

I checked,it looks good. The spellings are fine, brackets and stuff are closed, I don't know what to do. I can't see what's gone wrong. I ran this on replit.

CodePudding user response:

Maybe def modinverse(a,26) should be something like def modinverse(a,b) or def modinverse(a,b=26):?

In the first case you are declaring a parameter with the name 26.

  • Related