T
T
Tylen2020-07-23 21:48:00
Python
Tylen, 2020-07-23 21:48:00

Why doesn't palindrome search work?

Hello, I wrote a Python code to search for a palindrome, I don’t understand why it doesn’t display the correct results for me
Code:

p=0
for i in range(100,1000):
    for j in range(100,1000):
      p=i*j
      p=str(p)
    if p[:] == p[::-1]:
        print(p)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pikeev, 2020-07-23
@Tylen

Indents.

p = 0
    for i in range(100, 1000):
        for j in range(100, 1000):
            p = i * j
            p = str(p)
            if p[:] == p[::-1]:
                print(p)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question