마지막으로 search_target() 함수를 테스트해 봅시다.
코드 12-11 data_structure_1/linked_list.py ⑪
if __name__ = = "__main__": slist = Linked_list() print("데이터 개수: {}".format(slist.size())) show_list(slist) print() slist.append(3) slist.append(1) slist.append(5) slist.append(2) #26 slist.append(10) slist.append(7) slist.append(2) #27 print("데이터 개수: {}".format(slist.size())) show_list(slist) print('\n') data1, pos1 = slist.search_target(2) #28 if data1: print('searched data : {} at pos<{}>'.format(data1, pos1)) else: print('there is no such data') data2, pos2 = slist.search_target(2, pos1 + 1) #29 if data2: print('searched data : {} at pos<{}>'.format(data2, pos2)) else: print('there is no such data')