I don't understand why these are incorrect. Could someone please point out my errors?
@PeterUdacity In case my answers turn out to be correct, and since I've seen you ask others the same question: I did not use an external editor.
4.5 Better Splitting:
def split_string(source,splitlist):
list = []
start = 0
for i in range(len(source)):
if source[i] in splitlist:
if start < i:
list.append(source[start:i])
start = i + 1
else:
if i == len(source) - 1:
list.append(source[start:])
return list
4.6 Improving the Index
def add_to_index(index, keyword, url):
for entry in index:
if entry[0] == keyword:
if url in entry[1]:
return
entry[1].append(url)
return
index.append([keyword, [url]])
asked
21 Mar '12, 21:35
pseudonoob
200●3●12
accept rate:
40%