-4

I want to print a string that ends with the \ character, but the problem is it makes the following ") part of the string, so won't work. Is there any way to end a string with \ being considered a regular character?

print("somestuffhere\") and this is still part of that string...
reemer9997
  • 341
  • 1
  • 4
  • 7

1 Answers1

1

Put another "\" character behind it. This escapes the escape character. Like so:

print("somestuffhere\\")
Danny Herbert
  • 2,002
  • 1
  • 18
  • 26
  • @reemer9997 You should really look things like this up yourself though. This is a problem that everyone experiences when they first use an escape character in a string, making it very easy to research yourself. Keep that in mind when asking questions in future. :) – Danny Herbert Apr 25 '16 at 20:12