Aug-22-2024, 02:10 PM
from bs4 import BeautifulSoup
html="""
<html>
<head>
<meta charset="utf-8"/8>
<title>Hello</title>
</head>
<body>
<p>Hellow World1</p>
<p>Hellow World2</p>
<p>Hellow World3</p>
</body>
</html>
"""
sp=BeautifulSoup(html,"html.parser")
list1=sp.find_all("p")
print(list1)
print(len(list1))
for i in range(1,len(list1))
print(list1[i])
#for i in range(len(list1))
# print(list1[i].text)
what wrong of this python program?
The python show below error:
File "C:\Users\user\Documents\Beautifulsoup sample.py", line 19
for i in range(1,len(list1))
^
SyntaxError: expected ':'
html="""
<html>
<head>
<meta charset="utf-8"/8>
<title>Hello</title>
</head>
<body>
<p>Hellow World1</p>
<p>Hellow World2</p>
<p>Hellow World3</p>
</body>
</html>
"""
sp=BeautifulSoup(html,"html.parser")
list1=sp.find_all("p")
print(list1)
print(len(list1))
for i in range(1,len(list1))
print(list1[i])
#for i in range(len(list1))
# print(list1[i].text)
what wrong of this python program?
The python show below error:
File "C:\Users\user\Documents\Beautifulsoup sample.py", line 19
for i in range(1,len(list1))
^
SyntaxError: expected ':'