str
Season 02 - Introduction to Python Programming
Strings & Characters - Part1
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-5-6ac0306cdaf6> in <cell line: 1>() ----> 1 var - var1 TypeError: unsupported operand type(s) for -: 'str' and 'str'
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-6-057e19f0f1e8> in <cell line: 1>() ----> 1 var * var1 TypeError: can't multiply sequence by non-int of type 'str'
var3 = '''
This is sentence one
This is sentence two
This is sentence three
'''
print(type(var3))
print("")
print(var3)
<class 'str'>
This is sentence one
This is sentence two
This is sentence three
File "<ipython-input-11-d472829db0e4>", line 1 var = "Julius Caesar says, "Experience is the teacher of all things."" ^ SyntaxError: invalid syntax
Julius Caesar says, "Experience is the teacher of all things."
File "<ipython-input-13-25f80e072a07>", line 1 var1 = "lets print blackslash \" ^ SyntaxError: unterminated string literal (detected at line 1)
Julius Caesar says, "Experience is the teacher of all things."
lets print blackslash second part of the sentence
Julius Caesar says, "Experience is the teacher of all things."Julius Caesar says, "Experience is the teacher of all things."
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-24-5d113b0a9ea4> in <cell line: 1>() ----> 1 print(var / 2) TypeError: unsupported operand type(s) for /: 'str' and 'int'
[: end
] specifies from the beginning to the end offset minus 1
[ start
: end
] indicates from the start offset to the end offset minus
[ start
:] specifies from the start offset to the end.