Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 14
How can I print a sentence quote with the quotation marks untouched?
eg; a string with an output with it's quotes untouched "hello world".
30 Respostas
+ 10
print(' "hello world" ')
+ 10
if you want to include the quote characterĀ "Ā inside of a string? If you try to executeĀ print("I said "Wow!" to him")Ā thisĀ will give error. the problem is that Python sees one stringĀ "I said "followed by somethingĀ Wow!Ā which is not in the string. This is not what we intended!
PythonĀ doesĀ have two simple ways to put quote symbols in strings.
You are allowed to start and end a string literal with single quotes (also known as apostrophes), likeĀ 'blah blah'. Then, double quotes can go in between, such asĀ 'I said "Wow!" to him.'
You can put a backslash character followed by a quote (\"Ā orĀ \'). This is called anĀ escape sequenceĀ and Python will remove the backslash, and put just the quote in the string.
https://code.sololearn.com/cny1a64d9ryd/?ref=app
+ 5
use your brain please š”š”
+ 5
Jordan Alloyš
if I tell u a bit harsh to use your brain, I desperately try to teach you.
And I have confidence that u find the solution.
In my eyes you are a bit lazy.
It is a kick in your .... you know. š
+ 5
print(' "hello world" ') (quotation)
+ 5
G'day Jordan Alloyš.
You should go back and have a look at the very first batch of Python modules in Basic Concepts.
The lessons under the Strings module cover the "Escape Characters" SOUMYA SAHU is talking about, as well as what Oma Falk was saying.
+ 3
print(repr("hello'world"))
+ 2
Oma Falk look if your not interested in teaching me I suggest you just avoid my questions.
No one learn the way your coming off man!
+ 2
~ swim ~ thanks man, got it now.
One love
+ 2
Oma Falk you can say what you want bro, am trying to make use of my little resources to achieve great results, so don't tell me am lazy. You obviously don't know why I registered all those courses, and you don't know why my learning is progressive.
I'll take your insults as a credit bro, this place is filled with different people.
Using your limited perception on someone is wrong.
+ 2
šššššš šššš hmmm
Thanks
+ 2
Jan Markus thanks bud, learnt it.
š¼š¾
+ 2
Mark McClan done the review already, i totally understand now.
Thanks for your replies.
+ 2
Fariz Abduhakimov thank you
+ 2
print(ā\āhello world\āā)
+ 2
print ("\"write sentence\" ")
+ 2
You can also use triple single or triple double quotes.
print(""" "Hello" 'World!' """)
output: "Hello" 'World!'
+ 2
Use the escape sequence \" for printing the quotes, so that it will not be formatted.
+ 2
print("\"Hello World\" ")
+ 1
Oma Falk wow, i have spent time trying to make that possible. Thanks š