- 5
Strings
Some characters can't be directly included in a string. For instance, double quotes can't be directly included in a double quote string; this would cause it to end prematurely. Can someone explain and give an example of the meaning of this?
12 Answers
+ 13
If you do print(" " hi" ") it will give you error.
But you can do print(" 'hi' ") or print(' "hi" ')
+ 11
you can use the back-slash:
print("\"hi\"")
+ 4
" ":
The string starts at "
The string ends at the next "
So if you do " " hi " "
There are 2 empty strings and some unknown variable (hi) , causing error.
The same thing with ' '
+ 2
🌷 Alex Tusinean 🔥 and there is no operator between the Strings so that's an error source too
+ 2
Anton Böhler indeed.
+ 2
You can use the back-slash and this is known as 'escaping special characters'
Secondly, enclose you text in a pair of three apostrophes. Do as if you are doing documentation (like docustring). I have included an example of this code.
https://code.sololearn.com/cY4L3JdzwmzV/?ref=app
+ 1
String
Jika Anda ingin menggunakan teks dengan Python, Anda harus menggunakan string.
String dibuat dengan memasukkan teks antara dua tanda kutip tunggal atau ganda.
Ketika konsol Python menampilkan stri
+ 1
"\" "
0
You can't be use same quote inside same quote like outside
Ex ..you write ("my name is "yuwandeval" i m from delhi") if you write this you got error beacase whenever you compile the program compiler thought first quote is ("my ) this one but close of this quote is "yuwan deval..but it is not its close points soo...you got order...
Solition is that you use quote inside different quote so you never get error example
("My name is 'yuwan deval' and i m form ' delhi' yeap ")
Output.
My name is ' yuwan deval ' and i m from ' delhi' yeap.
0
I could not understand what is string
0
Anuth Gowda1, a string is a set of characters placed in quotes.
Perhaps read on data types for you to fully understand strings and what you can do or not do on them.
0
Use back Slash to print \