Not able to make the original source code work with or without a different parser.

0 Charles Beaver · September 25, 2015
I copied the source code and ran it and get:

for i in range(0, len(symbols):
SyntaxError: invalid syntax.

I was attempting to follow this code, and early on I was getting parser errors. So I installed html5lib and it would give me the error/s:

To get rid of this warning, change this:

 BeautifulSoup([your markup])

to this:

 BeautifulSoup([your markup], "html5lib")


I looked through the Beautiful Soup documentation and it didn't help much. I changed the
soup = BeautifulSoup(source_code) to

 BeautifulSoup([source_code], "html5lib")


after installing html5lib. But it still gave me the above error in a different format; stopping at the last )) at the end.

So I have 2 questions:

1) Why wouldn't the original source code work?
2) If I install the html5lib parser and change the code as I suggest, what is wrong with it at the end.

In other words, why can't I get this to work. I have seen it partially work; but, in the end, come up with errors after printing out many of the words. I never got to the point where it would count the frequencies of each word though.


Mike Beaver

Post a Reply


Oldest  Newest  Rating
0 Halcyon Abraham Ramirez · September 26, 2015
you are missing a parenthesis


for i in range(0, len(symbols):

should be:

for i in range(0, len(symbols)):
  • 1



This section is all about snakes! Just kidding.

Bucky Roberts Administrator