Python Forum
Probably easiest question ever
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Probably easiest question ever
#1
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.
Reply
#2
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")
ibreeden likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Easiest way to log into a site for web scraping? ejected 2 2,456 Mar-26-2019, 01:05 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

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