- 11
Correct the code and find the error
print('I'm learning Python!') print("A number enclosed in double quotes:42") Expected output: I'm learning Python! A number enclosed in double quotes:"42"
27 odpowiedzi
+ 7
Try this out:-
print("A number in double quotes:\"42\"")
+ 5
If u want to print double quotes:
print(' "42" in double quotes')
+ 4
Mr_Darkrai_47
There are 2 ways you can go about this that I know of:
(1) if you are enclosing the number in double quotes ("42"), then use single quotes ('') for your entire print statement. This is also valid the other way round. ie if you use single quotes for the number, your entire print statements should be in double quotes.
(2) You can escape the double quotes around the number by using a backslash(\) when the entire print statement is enclosed in the same quotation. Eg
print('I\'m learning Python!')
print("A number enclosed in double quotes: \" 42\"")
Hope this helps 👌
+ 2
print("{:>10s}".format(yourString)
+ 2
Oma Falk he have added a single quote at the end of the string.
That's why I prefer using backslash for escape sequences as it is much clearer and can be used in other languages also.
+ 2
print("I\'m learning python!")
+ 1
But it's showing incorrect though the output is same.
+ 1
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
print("I'm learning Python!")
print('A number enclosed in double quotes:"42" ')
Hope it is helpful for you
Any query regards you may ask😊
0
Thanks bro
0
Mr_Darkrai_47 hey!there is only one error in first line after print use double quotes ("").... print ("I'm learning python")
0
print('I\'m learning Python!')
0
Check out to this, if need explanation pin me!
print('I\'m learning Python!' + ' \n ' + 'A number enclosed in double quotes:"42"')
0
print("I\'m learning Python!")
print('A number enclosed in double quotes: "42\"')
0
Complete the code to output a string containing a single quote.
print('I
'm learning!')
- 1
print(" ")
- 1
no offense but is this complicated crap really necessary
i mean how often to people make statements like these in the real world
- 1
Complete the code to output a string containing a single quote.
print('I
'm learning!')
- 1
print("I\'m learning Python!")
print('A number enclosed in double quotes: "42\"')
- 1
1) print("I'm learning Python!")
2)
3) print('A number enclosed in double quotes: "42\"')
Try this it works👍👍