Skip to content
Advertisement

Syntax error in For loop because of searching for a “:” in Python

This is probably a really easy fix but I don’t know how to do it. I’m using Python.

JavaScript

I just want to search for og:title in description but the : in og:title keeps giving me a syntax error. I tried quotation marks but that didn’t work. I had the same problem with a – sign in another thing I was searching for. How do I make python treat them as just text? Sorry for bad question this is my first day ever coding

Advertisement

Answer

JavaScript

That’s not valid python code. Identifiers should contain alphanumeric and _ underscore characters. Avoid putting : colon in an identifier.

Spell it this way and you should be fine:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement