- 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"

14th Jul 2020, 6:49 AM
Beepboop
27 Respuestas
+ 7
Try this out:- print("A number in double quotes:\"42\"")
14th Jul 2020, 7:08 AM
Arsenic
Arsenic - avatar
+ 5
If u want to print double quotes: print(' "42" in double quotes')
14th Jul 2020, 7:09 AM
Oma Falk
Oma Falk - avatar
+ 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 👌
15th Jul 2020, 5:29 PM
👑 Tchybooxuur!
👑 Tchybooxuur! - avatar
+ 2
print("{:>10s}".format(yourString)
14th Jul 2020, 7:07 AM
Oma Falk
Oma Falk - avatar
+ 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.
14th Jul 2020, 7:16 AM
Arsenic
Arsenic - avatar
+ 2
print("I\'m learning python!")
24th Dec 2020, 5:22 PM
Sumeya Mim
Sumeya Mim - avatar
+ 1
But it's showing incorrect though the output is same.
14th Jul 2020, 6:53 AM
Beepboop
+ 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
14th Jul 2020, 11:34 PM
Lucky Sibanda
Lucky Sibanda - avatar
+ 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😊
15th Jul 2020, 12:48 PM
Ankita Yadav
Ankita Yadav - avatar
0
Thanks bro
14th Jul 2020, 7:09 AM
Beepboop
0
Mr_Darkrai_47 hey!there is only one error in first line after print use double quotes ("").... print ("I'm learning python")
14th Jul 2020, 5:14 PM
Navneet Kaur💫
Navneet Kaur💫 - avatar
0
print('I\'m learning Python!')
16th Jul 2020, 12:32 AM
Evenson Auguste
Evenson Auguste - avatar
0
Check out to this, if need explanation pin me! print('I\'m learning Python!' + ' \n ' + 'A number enclosed in double quotes:"42"')
10th May 2021, 9:11 AM
Vishal Sharma
Vishal Sharma - avatar
0
print("I\'m learning Python!") print('A number enclosed in double quotes: "42\"')
20th Oct 2021, 3:12 PM
Belete Yami Bati
0
Complete the code to output a string containing a single quote. print('I 'm learning!')
9th Feb 2023, 11:50 AM
mline
- 1
print(" ")
16th Jul 2020, 6:29 AM
AbdulWasi Sherzad
AbdulWasi Sherzad - avatar
- 1
no offense but is this complicated crap really necessary i mean how often to people make statements like these in the real world
21st Aug 2021, 8:30 PM
Reve Le
Reve Le - avatar
- 1
Complete the code to output a string containing a single quote. print('I 'm learning!')
26th Sep 2021, 3:57 PM
Mohammed Aarif
Mohammed Aarif - avatar
- 1
print("I\'m learning Python!") print('A number enclosed in double quotes: "42\"')
6th Jan 2022, 5:16 AM
Oscar D Diaz
Oscar D  Diaz - avatar
- 1
1) print("I'm learning Python!") 2) 3) print('A number enclosed in double quotes: "42\"') Try this it works👍👍
18th Mar 2022, 5:40 PM
Satish Kumar