< previous | Table of Contents | järgmine > |
6.6 COMMON ERRORS
TYPE ERRORS
As mentioned numerous times, strings are immutable and characters within a string cannot be altered. Trying to do so results in a TypeError
as can be seen from the Thonny example below.
Also, trying to concatenate types that do not match without converting them before, such as integer and string will lead to a TypeError
. Here you can see a brief example of such scenario in Thonny.
INDEX ERRORS
Accessing an index that is out of the range of the string length. Strings are indexed like lists, and attempting to access an index outside the range will result in an IndexError
.
< previous | Table of Contents | järgmine > |