Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Printing backslash

I just want to print a single backslash () in python terminal. If I use escape character '\' like this, I got two backslashes. I just want to print one.

Thanks for your help.

2 Answers

print("\") since single backslash represents an escape character

This is what I got: Python 3.5.0 (default, Aug 9 2017, 22:11:38)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.

'''print("\")'''
'print("")'
print("\")
File "<stdin>", line 1
print("\")
^
SyntaxError: EOL while scanning string literal