Python Forum

Full Version: Probably easiest question ever
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Just started coding for the first time with python. Trying to understand why I cannot write ''Hello World'' but can write 'Hello World'? It seems to cause me problems down the road when I write more lines

print(''Hello world'')
^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?

This problem comes up, must be the easiest solution to this.

Thanks in advance already.
You saw an example that used double quotes around a string and you thought it was two single quote characters. It is not. It is a single character. Two single quotes with no space between is an empty string. Python thought you wanted to print an empty string followed by something else. It complained that there was not a comma between the two.

You can do this.
print('Hello world')
Or you can do this, using the double quotes character.
print("Hello world")