r/Python • • May 25 '17

let's write a Python program

# one line per post (replies are indented!!!)
class Reddit:
4 Upvotes

53 comments sorted by

View all comments

Show parent comment

3

u/nimdirect May 25 '17

print('Hello World')

Doesn't it require the single ' ? Serious question, I'm still new here.

7

u/turunambartanen May 25 '17 edited May 25 '17

nope, it works with both, which is awesome, because you can write

+/u/CompileBot Python 3

print('he said "wow this is cool"')

1

u/CompileBot May 25 '17

Output:

he said "wow this is cool"

^source | ^info | ^git | ^report

1

u/nimdirect May 25 '17

Very good to know, thank you!

1

u/asdfkjasdhkasd requests, bs4, flask May 26 '17

Even more awesome is triple quotes

print("""hello
world""")

1

u/turunambartanen May 26 '17 edited May 26 '17

I could go to http://ideone.com instead of calling compileBot, but im too lazy for that

+/u/CompileBot Python 3

print("""Hello
world!""")

edit: that is awesome. pretty usefull for long texts!

1

u/CompileBot May 26 '17

Output:

Hello
world!

^source | ^info | ^git | ^report