+ 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".
32 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 😊