Dear Jussi, and Billy
I have changed the input in accordance with your advice, re:
------------------------------------------------------------------------------
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from bs4 import BeautifulSoup
>>> with open("ecologicalpyramid.html","r") as ecological_pyramid:
... soup = next(ecological_pyramid,"lxml")
... producer_entries = soup.find("ul")
... print(producer_entries.li.div.string)
... print(producer_entries.li.div.string)
File "<stdin>", line 5
print(producer_entries.li.div.string)
^
SyntaxError: invalid syntax
>>> print (producer_entries.li.div.string)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'producer_entries' is not defined
>>> from bs4 import BeautifulSoup
>>> with open("ecologicalpyramid.html","r") as ecological_pyramid:
... soup = next(ecological_pyramid,"lxml")
... producer_entries = soup.find("ul")
... print(producer_entries.li.div.string)
...
----------------------------------------------------------------------------
As no doubt you can see, the last line, indented as it is, does not provide the
output that the book's text says it will return - ie the word 'plants'
If I do not indent it, it returns an 'invalid syntax error' stating that
'producer_entries' is not defined. Though code in the previous line is meant to
do just that - isn't it ?
--
https://mail.python.org/mailman/listinfo/python-list