1

Hello here is my python code:

def is_palindrome(nombre):
    if str(nombre) == str(nombre)[::-1]:
        return True
    return False
x = 0
for i in range(100, 1000):
    for j in range(i, 1000):
        for z in range(j, 1000):    
 produit = i*j*z

        if is_palindrome(produit):
            if produit > x:
                x = produit
print(x)

When I tried to compile this code I have got that error: produit = ijz ^ IndentationError: unindent does not match any outer indentation level Anyone has an idea please??

plamut
  • 3,085
  • 10
  • 29
  • 40
nour
  • 538
  • 2
  • 7
  • 16
  • 5
    I have an idea of the problem: the unindent doesn't match any outer indentation level. Indentation matters in Python, so you have to fix it. Check how many spaces you're using per level, check if you have tabs anywhere, and so on. – TigerhawkT3 Jan 27 '16 at 11:49
  • in fact : the program was working however when I added for z in range(j, 1000): and I multiplied i and j by z I got the error – nour Jan 27 '16 at 11:52
  • I didn't understand why – nour Jan 27 '16 at 11:53
  • 1
    Because the code you added used indentation levels that didn't match up. Without an assurance that your posted code _exactly matches_ the indentation in your program, that's all I can say. – TigerhawkT3 Jan 27 '16 at 11:54
  • As it looks now, the indentation is clearly wrong for the line `produit = i*j*z` – khelwood Jan 27 '16 at 11:59

2 Answers2

3

You can check for problems with tabs/spaces also in command line:

python -m tabnanny -v yourfile.py
G4mo
  • 597
  • 1
  • 8
  • 18
1

The code in your question is a mess. Here's how it could probably look like with the indentation fixed.

def is_palindrome(nombre):
    if str(nombre) == str(nombre)[::-1]:
        return True
    return False

x = 0
for i in range(100, 1000):
    for j in range(i, 1000):
        for z in range(j, 1000):    
            produit = i*j*z

            if is_palindrome(produit):
                if produit > x:
                    x = produit
# you may want to move this into the inner `if` statement
print(x)
ForceBru
  • 43,482
  • 10
  • 63
  • 98