'johnjohnthere is logic to this just as the expression * is equivalent to + + the expression *'ais equivalent to ' '+' '+'anow try typing ' '*'aeach of these lines generates an error message the first line produces the message nameerrorname 'ais not defined because is not literal of any typethe interpreter treats it as name howeversince that name is not bound to any objectattempting to use it causes runtime error the code ' '*'aproduces the error message typeerrorcan' multiply sequence by non-int of type 'strthat type checking exists is good thing it turns careless (and sometimes subtlemistakes into errors that stop executionrather than errors that lead programs to behave in mysterious ways the type checking in python is not as strong as in some other programming languages ( javafor exampleit is pretty clear what should mean when it is used to compare two strings or two numbers but what should the value of ' berather arbitrarilythe designers of python decided that it should be falsebecause all numeric values should be less than all values of type str the designers of some other languages decided that since such expressions don' have an obvious meaningthey should generate an error message strings are one of several sequence types in python they share the following operations with all sequence types the length of string can be found using the len function for examplethe value of len('abc'is indexing can be used to extract individual characters from string in pythonall indexing is zero-based for exampletyping 'abc'[ into the interpreter will cause it to display the string 'atyping 'abc'[ will produce the error message indexerrorstring index out of range since python uses to indicate the first element of stringthe last element of string of length is accessed using the index negative numbers are used to index from the end of string for examplethe value of 'abc'[- is 'cslicing is used to extract substrings of arbitrary length if is stringthe expression [start:enddenotes the substring of that starts at index start and ends at index end- for example'abc'[ : 'bcwhy does it end at index end- rather than endso that expressions such as 'abc'[ :len('abc')have the value one might expect if the value before the colon is omittedit defaults to if the value after the colon is omittedit defaults to the length of the string consequentlythe expression 'abc'[:is semantically equivalent to the more verbose 'abc'[ :len('abc')