I’m kinda’ new to python, but I have already written many programs including some like download-managers, games and text-editors which require a lot of string manipulation.
For representing a string literal I use either single or double inverted commas.. whichever comes to my mind first at that time.
Although I haven’t yet faced any trouble. My question: is there any purpose for which python allows both or is it just for compatibility, usability etc?
There is no difference between
"string"and'string'in Python, so, as you suggest, it’s just for usability.You can also use triple quotes for multiline strings:
Another trick is that adjacent string literals are automatically concatenated:
There are also string prefixes which you can read about in the documentation.