I am wondering why this is correct:
for heading in soup.find_all("td", class_="paraheading"):
key = " ".join(heading.text.split()).rstrip(":")
if key in columns:
print key
next_td = heading.find_next_sibling("td", class_="bodytext")
value = " ".join(next_td.text.split())
print value
if key == "Industry Categories":
print key
ic_next_td = heading.find_next_sibling("td", class_="bodytext")
for value in ic_next_td.strings:
print value
and this is not:
for heading in soup.find_all("td", class_="paraheading"):
key = " ".join(heading.text.split()).rstrip(":")
if key in columns:
print key
next_td = heading.find_next_sibling("td", class_="bodytext")
value = " ".join(next_td.text.split())
print value
if key == "Industry Categories":
print key
ic_next_td = heading.find_next_sibling("td", class_="bodytext")
for value in ic_next_td.strings:
print value
note seemingly double indentation of print value in first code block.
Wouldn’t the next level of indentation down from for value in ic_next_td.strings: be one additional indentation level from this line?
Thanks
You are mixing tabs and spaces. Don’t do this.
Run
python -tt yourscript.pyto detect any inconsistencies, but most of all, use spaces only throughout.Configure your editor to use spaces for indentation, and replace all existing tabs with spaces. Most code editors have a function for that.