+ 3

Can someone explain a backslash ?

WHAT AM I SUPPOSED TO DO IVE BEEN STUCK ON THIS FOR DAYS

12th Feb 2020, 1:20 AM
Nadia
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 ".
12th Feb 2020, 1:27 AM
HonFu
HonFu - avatar
+ 4
The backslash is often called an escape character in this context.
12th Feb 2020, 1:29 AM
Sonic
Sonic - avatar
+ 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.
12th Feb 2020, 1:31 AM
Sonic
Sonic - avatar
+ 3
Nadia bacslashes used like that are helpful in Python, C and many other languages.
12th Feb 2020, 1:41 AM
Sonic
Sonic - avatar
+ 3
Nadia I guess this is the question you had trouble with? https://www.sololearn.com/post/241438/?ref=app
12th Feb 2020, 2:32 AM
Sonic
Sonic - avatar
+ 1
in pythin is that helpful in any way im still knew to all this
12th Feb 2020, 1:39 AM
Nadia
+ 1
oh so the ither languages use simliar symbols?
12th Feb 2020, 1:44 AM
Nadia
+ 1
im a bit confused
12th Feb 2020, 1:44 AM
Nadia
+ 1
It's helpful whenever you want to print a " to the screen instead of getting an error.
12th Feb 2020, 1:44 AM
HonFu
HonFu - avatar