Explore your training options and get exclusive tuition discounts Get Started

X

Back

James Gallagher

Technical Content Manager

James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.

Python NameError: name ‘self’ is not defined Solution
The value “self” is only available inside a method when a function is called and specified. You cannot access “self” in the arguments specified to a method, or inside a function without specifying “self” as an argument. Otherwise, you see…
Python ValueError: I/O operation on closed file Solution
You can only read from and write to a Python file if the file is open. If you try to access or manipulate a file that has been closed, the “ValueError : I/O operation on closed file” appears in your…
Python TypeError: ‘function’ object is not subscriptable Solution
Unlike iterable objects, you cannot access a value from a function using indexing syntax. Even if a function returns an iterable, you must assign the response from a function to a variable before accessing its values. Otherwise, you encounter an…
Python SyntaxError: non-default argument follows default argument Solution
An argument can have a default value in a Python function. If you specify arguments with default values, they must come after arguments without default values. Otherwise, you encounter a “SyntaxError: non-default argument follows default argument” error. In this guide,…
Python TypeError: ‘tuple’ object is not callable Solution
Tuples are enclosed within parentheses. This can be confusing because function calls also use parenthesis. If you use parentheses to access items from a tuple, or if you forget to separate tuples with a comma, you’ll encounter a “TypeError: 'tuple'…
Python TypeError: ‘float’ object not iterable Solution
Python can only iterate over an iterable object. This is a type of object that can return its members one at a time. If you try to iterate over a non-iterable object, like a floating-point number, you see an error…
Python TypeError: unhashable type: ‘dict’ Solution
The Python language is specific about what can be used as a key in a dictionary. In a Python dictionary, all keys must be hashable. If you try to use an unhashable key type when adding a key to a…
Python indentationerror: unindent does not match any outer indentation level Solution
Indenting your code can be a messy business if you try to use both spaces and tabs. In Python, using both methods of indentation results in an error. This error is “indentationerror: unindent does not match any outer indentation level”.…
Python ModuleNotFoundError Solution
Modules are integral to the Python language. Modules let you break down your code into multiple files. This helps maintain the readability and maintainability of a codebase. It’s common to encounter a ModuleNotFoundError when working with modules. In this guide,…
Python TypeError: not enough arguments for format string Solution
Python strings must be formatted using the correct number of arguments. When the number of arguments you specify is less than the number of values you want to format into a string, you encounter an error like “TypeError: not enough…
Python missing 1 required positional argument: ‘self’ Solution
Python classes need to be instantiated, or called, before you can access their methods. If you forget to instantiate an object of a class and try to access a class method, you encounter an error saying “missing 1 required positional…
Python typeerror: ‘>’ not supported between instances of ‘str’ and ‘int’ Solution
You can only compare items using mathematical operators if they have the same numerical data type. If you try to compare a string and an integer, you’ll encounter an error that says “not supported between instances of ‘str’ and ‘int’”.…
Python TypeError: ‘dict’ object is not callable Solution
Items in a Python dictionary must be called using the indexing syntax. This means you must follow a dictionary with square brackets and the key of the item you want to access. If you try to use curly brackets, Python…
Python takes 1 positional argument but 2 were given Solution
When you call a method associated with an object, there is one positional argument that is supplied by default: self. If you forget to include “self” when you define a method, you’ll encounter an error that says “takes 1 positional…
Python TypeError: string index out of range Solution
Like lists, Python strings are indexed. This means each value in a string has its own index number which you can use to access that value. If you try to access an index value that does not exist in a…
Python AttributeError: ‘str’ object has no attribute ‘append’ Solution
The append() method adds items to the end of a list. It cannot be used to add items to a string. Python returns an error stating “AttributeError: ‘str’ object has no attribute ‘append’” if you try to add values to…
Python TypeError: ‘int’ object is not callable Solution
Curly brackets in Python have a special meaning. They are used to denote a function invocation. If you specify a pair of curly brackets after an integer without an operator between them, Python thinks you’re trying to call a function.…
Python attributeerror: ‘list’ object has no attribute ‘split’ Solution
Python lists cannot be divided into separate lists based on characters that appear in the values of a list. This is unlike strings which values can be separated into a list. If you try to use the split() method on…
Rename Column in Pandas: A Beginner’s Guide
So you want to rename a column in a Python Pandas dataframe. Is that possible? Yes, it is. You use the rename() method to rename an individual column or the “columns” attribute to assign a new set of column headers…
Python typeerror: ‘str’ object is not callable Solution
Mistakes are easily made when you are naming variables. One of the more common mistakes is calling a variable “str”. If you try to use the Python method with the same name in your program,  “typeerror: ‘str’ object is not…
Python SyntaxError: unexpected EOF while parsing Solution
Python is a statically typed language. This means it’s strict about how code is written. If you forget to complete a code block in your code, you get an error like “SyntaxError: unexpected EOF while parsing”. This happens in a…
Python TypeError: unsupported operand type(s) for -: ‘str’ and ‘int’ Solution
Integer values cannot be subtracted from string values and vice versa. This is because strings and integers are separate data types. If you try to subtract a string from an integer, you receive an error like “TypeError: unsupported operand type(s)…
Python local variable referenced before assignment Solution
When you start introducing functions into your code, you’re bound to encounter an UnboundLocalError at some point. This error is raised when you try to use a variable before it has been assigned in the local context. In this guide,…
Python IndexError: tuple index out of range Solution
Like lists, Python tuples are indexed. This means each value in a tuple has a number you can use to access that value. When you try to access an item in a tuple that does not exist, Python returns an…
Python ValueError: invalid literal for int() with base 10 Solution
Python is good at converting values to different data types. You can convert strings to integers, integers to strings, floats to integers, to name a few examples. There’s one conversion Python does not like: changing a float structured as a…
How Long Should a Cover Letter Be?
How long should a cover letter be? A cover letter should be no longer than one page and no less than half a page. It should be divided into four paragraphs. This length shows hiring managers why you're right for…
JavaScript Random Number: A Complete Guide
To create a random number in Javascript, the math.random() function is used. JavaScript math.random() generates a random decimal value between 0 and 1. The function does not take any arguments. To get random numbers higher than 1 simply multiply the…
Python valueerror: too many values to unpack (expected 2) Solution
Python does not unpack bags well. When you see the error “valueerror: too many values to unpack (expected 2)”, it does not mean that Python is unpacking a suitcase. It means you are trying to access too many values from…
fatal: not a git repository (or any of the parent directories): .git
An error that begins with “fatal” never sounds good. Do not worry; the cause of the fatal: not a git repository (or any of the parent directories): .git error is simple. This error is raised when you try to run…
Python TypeError: ‘module’ object is not callable Solution
Python modules are confusing, especially when you define your own. “TypeError: ‘module’ object is not callable” is one of the most common mistakes that Python developers make when working with classes. In this guide, we talk about what this error…
Start your Tech training
Find, compare, and enroll in the right training program. Save on Tuition.
View my matches