The question about Hoemoon coding ^^ (Super beginner)

Asked 2 years ago, Updated 2 years ago, 17 views

Hello.

I understand the conversation. I've been following Python Hoemun on the internet, and number one works well.

I made number 2 and copied it.False, false, false, false. It comes out five times. (A month-old beginner of Python Wang asks a question. nodding ). Replace #2 well. ㅜ.ㅜ

).).

1. word = input('Enter a word:')

is_palindrome = True
for i in range(len(word) // 2):
if word[i] != word[-1 - i]:
is_palindrome = False
break

print(is_palindrome)

2. words = ['big', 'level', 'levpel', 'pson', 'level']

is_palindrome = True

for word in words:

for i in range(len(word) // 2):

    if word[i] != word[-1 - i]:

        is_palindrome = False

        break

print(is_palindrome)

python

2022-09-22 13:57

1 Answers

Move the is_palindrome = True part to the logic below for word in words: This is a problem caused by the bullion not being initialized.


2022-09-22 13:57

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.