Sintax error

This is the place for queries that don't fit in any of the other categories.

Sintax error

Postby amchacon » Mon Jul 01, 2013 7:29 am

I am starting with python. I am translating one function that i had in C++:

Code: Select all
def Resolver(Tablero):
   
    if Explora(Tablero,MAX,MAX) == False:
        return false;
   
    if Resuelto(Tablero) == True:
        return true;
   
    for j in range(9):
        for i in range(9):
            if Tablero[i][j] != None:
            Valores = EncontrarPosibilidades(Tablero,i,j)
            
            tablero = [None] * 9
            
            for k in range(9):
                  tablero[k] = [None] * 9
            
            
                for it in Valores:

                    for k in range(9):
                        for l in range(9):
                            tablero[l][k] = Tablero[l][k]

                    tablero[i][j] = it

                    if (Resolver(tablero))
                   
                        for k in range(9)
                            for l in range(9)
                                Tablero[l][k] = tablero[l][k];

                        return true;
                   

               

   return false;


Screenshot of the editor: http://imageshack.us/a/img194/4031/y4o.png

I have one error in "EncontrarPosibilidades(Tablero,i,j)":

Image

I dont understand (¡it´s indented!)
amchacon
 
Posts: 2
Joined: Mon Jul 01, 2013 7:21 am

Re: Sintax error

Postby micseydel » Mon Jul 01, 2013 11:20 am

You have an if block but your code isn't indented. In Python, indentation does what curly braces ({,}) do in C.
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 1117
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Sintax error

Postby amchacon » Mon Jul 01, 2013 12:30 pm

Thanks but were indexted (check screenshot), was a problem while copy&pasting.

I solved it, Notepad do bad tabulations. Can be solved in Settings -> Language -> Do tabulations with spaces.
amchacon
 
Posts: 2
Joined: Mon Jul 01, 2013 7:21 am

Re: Sintax error

Postby ochichinyezaboombwa » Mon Jul 01, 2013 2:52 pm

Yepp, "sintax error"... ( should be "syntax error") LOL.
ochichinyezaboombwa
 
Posts: 200
Joined: Tue Jun 04, 2013 7:53 pm

Re: Sintax error

Postby micseydel » Mon Jul 01, 2013 5:24 pm

You really shouldn't be using notepad for programming. There are a great many free tools designed for programming, you can google them and try some for yourself.
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 1117
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Sintax error

Postby stranac » Mon Jul 01, 2013 7:25 pm

You can see in the screenshot that he's using notepad++, which is actually decent-ish.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1093
Joined: Thu Feb 07, 2013 3:42 pm

Re: Sintax error

Postby micseydel » Tue Jul 02, 2013 12:28 am

I tend to not follow people's links.
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 1117
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot] and 6 guests