강의

멘토링

커뮤니티

Inflearn Community Q&A

bsm72103507's profile image
bsm72103507

asked

I opened my eyes and it was the day before the coding test.

Insertion sort

코드 한번 봐주실수 있나요..? 이해가 안되서 그래요ㅡㅜㅜ

Written on

·

321

0

##


list_n = [2,1,3,4,5,76,1,83,277,89,73]
list_d = []

# while list_n:
# insert_v = list_n.pop(0)




for i in list_n:
if len(list_d) == 0:
list_d.append(i)
print("s :", list_d)
else :
print("\n", "== else ==")
for saved in list_d:

print( "i : ", i, " j :", saved)
if i < saved:
print(",,,,,,,,",list_d.index(saved))
list_d.insert(list_d.index(saved), i)
print(list_d)
break
if list_d.index(saved) == len(list_d)-1:
list_d.append(i)
break


print(list_d)
print("for_1")

 

이렇게 짯는데 break 문이 없으면 무한반복하더라구요..

근데 이유를 모르겠어요..

일단넣으니 됬는데 이유가 궁금합니다

코테 준비 같이 해요!

Answer

This question is waiting for answers
Be the first to answer!
bsm72103507's profile image
bsm72103507

asked

Ask a question