Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- index = { WORD, [url1,url2,url3] }
- def update_index(word, url):
- if word in index and not(url in index[word]):
- index[word].append(url) # list already exists append to it
- else:
- index[word] = [url] # new list with url as a single element
- def update_index(word, url):
- if word in index: # <- isnt having two consecutive if statements
- # the same as an AND???
- if not(url in index[word]):
- index[word].append(url) # list already exists append to it
- else:
- index[word] = [url] # new list with url as a single element
- from collections import defaultdict
- url_store = defaultdict(set)
- url_store[word].add(url)
- if word not in index:
- index[word] = [] # create new empty list for word
- # now we know that a list exists -> append
- if url not in index[word]:
- index[word].append(url)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement