Correct the code and find the error | SoloLearn: Learn to code for FREE!

+5

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"

7/14/2020 6:49:31 AM

Mr_Darkrai_47

15 Answers

New Answer

+10

Try this out:- print("A number in double quotes:\"42\"")

+7

If u want to print double quotes: print(' "42" in double quotes')

+6

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.

+4

Arsenic Here's the actual purpose of using \ for inverted commas print("''"""'"'"'") print("\'\'\"\"\"\'\"\'\"\'") Output : ''"' ''"""'"'"'

+2

print("{:>10s}".format(yourString)

+2

Thanks bro

+2

Mr_Darkrai_47 print("I'm learning Python!") print('A number enclosed in double quotes:"42"')

+2

Oma Falk Please ,Run my code first I always answer after executing the code & it positioned me 3 or 4th in comments ;)

+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

+2

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😊

+2

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 👌

+1

But it's showing incorrect though the output is same.

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

print(" ")