i thought knew different types of python quotations mean, got little confused example:
my_string = 'the cat sat on mat' my_string = "the cat sat on mat" my_string = """the cat sat on mat""" my_string = '''the cat sat on mat'''
the first 2 seem 2 different ways of declaring string using single or double quotes. last 2 seem comments leave expressions incomplete (and generate error in interpreter. right?
the last 2 not comments , multi-line strings, if print out last 2 strings see output on console.
my_string3 = """the cat sat on mat""" print my_string3 >>> cat sat on mat
if """..."""
denoted comment must have received error message while initializing such variable a = #dad
raise error.
as strings initialized """
multi-line can initialize strings as:
my_string3 = """the cat sat on mat""" print my_string3 >>> cat sat on mat
Comments
Post a Comment