좋은 알고리즘이란?알고리즘이란?선수 과제

Q

stars가 True 로 나오는 이유에 대해서 설명해주세요

조회 1969

좋아요 10

2019년 7월 14일

천익환

LV

9

천익환 Profile

천익환

LV

9

천익환 Profile



댓글 1

2020년 12월 29일
def is_palindrome(word):
# 코드를 입력하세요.
for left in range(len(word) // 2):
# "racecar" -> len(word) = 7, 7 // 2 = 3 => left = 3
# word[left] = 0, 1, 2
right = len(word) - left - 1
# left = 0, right = 7 - 0 - 1 = 6
# left = 1, right = 7 - 1 - 1 = 5
# left = 2, right = 7 - 2 - 1 = 4
if word[left] == word[right]:
# word[0] == word[6]
# word[1] == word[5]
# word[2] == word[4]
continue
# if statement is true, continue
return False
# if statement is false, stop and return False

return True
# for statement is completely procedeed, stop and return True
A
3개의 답변이 있어요
커뮤니티 파트너 채택



랑이
최고의 멘토
LV. 211

채택된 답변 수 2,761

2019년 7월 14일



jayone
LV. 15

채택된 답변 수 1

2020년 2월 23일



나참
LV. 17
2020년 12월 29일

(주) 코드잇

대표강영훈

개인정보보호책임자강영훈

이메일support@codeit.kr

사업자 번호313-86-00797

통신판매업제 2019-서울중구-1034 호

주소서울특별시 중구 청계천로 100 시그니쳐타워 동관 10층 코드잇