-4

I just started to learn python3 2 or 3 days ago so I'm a total noob. I'm learning from a book called How to think like a computer scientist and it uses python2 ann not python3 ... I got stuck when it told me about backslash character... and i can't find anything on the internet ....

print("This is a test /n This is a test")

What the book says is that i should get something like this:

This is a test
This is a test

But what I do get is:

This is a test /n This is a test

Am I doing something wrong?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Eeren
  • 3
  • 3

2 Answers2

4

The backslash is the other slash, \:

>>> print('This is a test \n This is a test')
This is a test 
 This is a test

You are using a forward slash, /, instead.

Also see the tag wiki excerpt:

The backslash character \ (not to be confused with slash /)...

Community
  • 1
  • 1
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
2

You are using a forward slash / and not a backslash \

print("This is a test \n This is a test")
This is a test 
This is a test
Yuvika
  • 5,624
  • 2
  • 16
  • 21