Home > OS >  Why "SyntaxError: invalid syntax. Perhaps you forgot a comma?"
Why "SyntaxError: invalid syntax. Perhaps you forgot a comma?"

Time:07-15

I'm trying to execute the following code, but I keep on getting this error. I've checked tutorials of "map" & "lambda" over and again, but couldn't discover the issue. Kindly help.

import re
import requests

source = requests.get('https://www.youtube.com/c/CoinBureau/videos').text
URLs = re.findall("/watch\?v=\w*", source)
URL_IDs = list(map(lamda x: x[9:], URLs))

CodePudding user response:

You have a minor typo. The spelling of lambda is wrong.

Fix the error here

URL_IDs = list(map(lamda x: x[9:], URLs))

with the following

URL_IDs = list(map(lambda x: x[9:], URLs))

CodePudding user response:

Try to use ():

import re
import requests

source = requests.get('https://www.youtube.com/c/CoinBureau/videos').text
URLs = re.findall("/watch\?v=\w*", source)
URL_IDs = list(map(lambda x: (x[9:]), URLs))

btw, you wrote lamda instead of lambda

  • Related