Last answered:

30 Dec 2022

Posted on:

24 Dec 2022


about expression

Can you please elaborate why you use backslash and  apostrophe mark
in front and end of data in the following code:
print('The sum of \'data\' is :',total)

1 answers ( 0 marked as helpful)
Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
Posted on:

30 Dec 2022


HI Ayush,
    Within the print string, from the first ' to the final ', if you wish to include another ' or a set of ', you need to use an ESCAPE character, which is \ (backslash).  This is how the output shows The sum of 'data' is: not just The sum of data is:
    Same process if you wanted to print Data's sum is: you would have to use 'Data\'s sum is:'
Link above gives same details - from 2:40 in the video.....
Or Page 8 'Introduction to Python - Course Notes' with the video examples.

Hope this helps.
Kev T.

Submit an answer