
Print('I have ' + str(numEggs) + ' eggs.')ħ) Forgetting a quote to begin or end a string value. What you want to do is this: numEggs = 12
#TYPE ERROR IN THONNY CODE#
This error happens with code like this: numEggs = 12 (Causes “ TypeError: Can't convert 'int' object to str implicitly”)

What you probably want is this: spam = 'I have a pet cat.'Ħ) Trying to concatenate a non-string value to a string value. This error happens with code like this: spam = 'I have a pet cat.' (Causes “ TypeError: 'str' object does not support item assignment”) But the above is for the very legitimate case where you need the index in the body of the loop, rather than just the value itself.)ĥ) Trying to modify a string value. (Update: As a few have pointed out, what you might need is just for i in spam: rather than the above code. This error happens with code like this: spam = Just remember to pass the return value of len(someList), instead of passing just someList. (Causes “ TypeError: 'list' object cannot be interpreted as an integer”)Ĭommonly you want to iterate over the indexes of items in a list or string, which requires calling the range() function. This error happens with code like this: print('Hello!')Ĥ) Forgetting the len() call in a for loop statement. Remember that the indentation only increases after a statement ending with a : colon, and afterwards must return to the previous indentation. (Causes “ IndentationError: unexpected indent” and “ IndentationError: unindent does not match any outer indentation level” and “ IndentationError: expected an indented block”) This error happens with code like this: if spam = 42:ģ) Using the wrong amount of indentation.

The = is the assignment operator while = is the "is equal to" comparison operator. This error happens with code like this: if spam = 42Ģ) Using = instead of =. Here's a list of common errors that result in runtime error messages which will crash your program.ġ) Forgetting to put a : at the end of an if, elif, else, for, while, class, or def statement. Figuring out what Python's error messages mean can be kind of tricky when you are first learning the language.
