nour
nour

Reputation: 568

IndentationError: unindent does not match any outer indentation level python

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??

Upvotes: 1

Views: 14054

Answers (2)

G4mo
G4mo

Reputation: 607

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

python -m tabnanny -v yourfile.py

Upvotes: 3

ForceBru
ForceBru

Reputation: 44838

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)

Upvotes: 1

Related Questions