+ 3
Can someone explain a backslash ?
WHAT AM I SUPPOSED TO DO IVE BEEN STUCK ON THIS FOR DAYS
9 ответов
+ 3
A computer is very quick, but dumb. It can't read your mind and know what you intended to write.
If you write " Python will assume a string starts, and as soon as it sees another " Python will think the string ends.
So when you write:
print("Judy said: "Hello"")
Python only gets to this point:
print("Judy said: "H
Python thinks your string has ended, and now it doesn't know what to do with your H.
You use a \ to tell Python: 'The string is not yet over!'
print("Judy says: \"...
Now, as Python finds the backslash, it 'understands': Ah, so the string is not over yet!
It will wait for the first unmasked ".
+ 4
The backslash is often called an escape character in this context.
+ 3
We're guessing that you're referring to backslash in the context that HonFu described as your question does not say too much about where you encountered it.
+ 3
Nadia I guess this is the question you had trouble with?
https://www.sololearn.com/post/241438/?ref=app
+ 1
in pythin is that helpful in any way im still knew to all this
+ 1
oh so the ither languages use simliar symbols?
+ 1
im a bit confused
+ 1
It's helpful whenever you want to print a " to the screen instead of getting an error.