Ask coding questions

← Back to all posts
[RESOLVED] help printing a specific line
21Miya

I'd like to print this exact output as an example of a print statement in a Python tutorial project:

print("Hello world!")

I'm a little rusty on Python after using Ruby for so long and am not sure how to avoid a syntax error (because of the quotes and parentheses inside of the print statement).

Does anyone know how to fix this? Thanks in advance!

Voters
21Miya
Comments
hotnewtop
wsgdandy

Use this; print('print("Hello world!")') Hope this helps you for future reference, happy coding.

21Miya

@wsgdandy I can't believe I forgot I could do this. Thank you for the refresher!

JustCoding123

Put a \ before your "s in the string. So it will be: print("print(\"Hello world!\")").
Or you can put the string in 's then it will be print('print("Hello world!")').

21Miya

@JustCoding123 Thank you!