0

I am new to Python and i want to display this message in the console:

'print("Hello")'

How can we obtain that? is it necessary to do some magic behind?

we can do this:

print("'print('hello')'")

but the output is this:

'print('hello')'
wjandrea
  • 28,235
  • 9
  • 60
  • 81
JustToKnow
  • 785
  • 6
  • 23
  • print('\'print(\"Hello\")\'') – alexander Mar 24 '22 at 21:53
  • hey @alexander thnks for replying! I am kinda confused. Why is it necessaary to use "\". I dont get it – JustToKnow Mar 24 '22 at 21:55
  • 1
    https://en.wikipedia.org/wiki/Escape_character the backlash tells the python interpreter to 'make it part of the string'. there are other special characters such as \n. try print('hello \n\n world') i would recommend reading the first 3 chapters of this pdf for general programming knowledge: https://kremlin.cc/k&r.pdf – alexander Mar 24 '22 at 22:01
  • Thanks, gonna check it put, pal! – JustToKnow Mar 24 '22 at 22:03

0 Answers0