Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can't assign to operator
#1
I am trying to scrap this jokes from the website but i get the assignment operator error
from urllib.requests import urlopen as uReq
from bs4 import BeautifulSoup as soup 

quotes_page = 'http://www.laughfactory.com/jokes/yo-momma-jokes'

uClient = uReq(quotes_page)
page_html = uClient.read()
uClient.close()

page_soup = soup(page_html, "html.parser")
quotes = page_soup.findAll("div",{"class":"jokes"})

for quote in quotes:
	fav_quote = quote.findAll("div",{"class":"joke-msg"})
	joke-msg = fav_quote[0].text.stip()

	fav_authors = quote.findAll("div",{"class":"joke-text"})
	joke-text = fav_authors[0].text.strip()

	print (joke-msg)
	print (joke-text)
Error messsage
  File "yomama.py", line 17
    joke-msg = fav_quote[0].text.stip()
    ^
SyntaxError: can't assign to operator
Reply
#2
please, post the full traceback you get in error tgs
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Variables can't have a dash in them. You can use underscores instead though.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020