Skip to content

Instantly share code, notes, and snippets.

@rcackerman
Created October 30, 2014 00:24
Show Gist options
  • Select an option

  • Save rcackerman/7e5670a43f7fdd052d2e to your computer and use it in GitHub Desktop.

Select an option

Save rcackerman/7e5670a43f7fdd052d2e to your computer and use it in GitHub Desktop.
Why isn't this working?? :-(
def get_dict_keys(url):
keys = []
op = s.urlopen(url)
bs = BeautifulSoup(op)
keys_th = bs.find('table', class_ = 'intv').find('tr').find_all('th')
[keys.append(key.string) for key in keys_th]
print keys
keys
@rcackerman

Copy link
Copy Markdown
Author

Because there's no return - duh.

def get_dict_keys(url):
keys = []
op = s.urlopen(url)
bs = BeautifulSoup(op)
keys_th = bs.find('table', class_ = 'intv').find('tr').find_all('th')
[keys.append(key.string) for key in keys_th]
print keys
return keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment