Python is a popular programming language used to develop websites, analyze data, and automate tasks. These various Python articles provide information on courses, resources, books, and communities to help you learn this coding language. There is also a handy glossary of Python terminology, quizzes and exercises, and specific resources for various career paths.
Learn Python
Python ValueError: max() arg is an empty sequence Solution
The max() method only works if you pass a sequence with at least one value into the method. If you try to find the largest item in an empty list, you’ll encounter the error “ValueError: max() arg is an empty…
Python typeerror: ‘tuple’ object does not support item assignment Solution
Tuples are immutable objects. “Immutable” means you cannot change the values inside a tuple. You can only remove them. If you try to assign a new value to an item in a variable, you’ll encounter the “typeerror: ‘tuple’ object does…
Python: Initialize List of Size N
You cannot assign items to a list at positions that do not exist. This is because lists are indexed from zero and new index positions increment by one each time an item is added to a list. This means if…
Python TypeError: unhashable type: ‘list’ Solution
Python dictionaries only accept hashable data types as a key in a dictionary. A list is not a hashable data type. If you specify a list as a key in a dictionary, you’ll encounter a “TypeError: unhashable type: ‘list’” error.…
Python IndentationError: unexpected indent Solution
IndentationErrors serve two purposes: they help make your code more readable and ensure the Python interpreter correctly understands your code. If you add in an additional space or tab where one is not needed, you’ll encounter an “IndentationError: unexpected indent”…
Python TypeError: ‘nonetype’ object is not callable Solution
Objects with the value None cannot be called. This is because None values are not associated with a function. If you try to call an object with the value None, you’ll encounter the error “TypeError: 'nonetype' object is not callable”.…
Python IndentationError: expected an indented block Solution
Python indentation is a stickler. You must correctly indent your code. If you use the wrong arrangement of spaces and tabs in a Python program, you encounter the “IndentationError: expected an indented block” error. In this guide, we talk about…
Python TypeError: object() takes no arguments Solution
The arguments a class object accepts are passed through a function called __init__(). If you misspell this function in your class declaration, you’ll encounter a “TypeError: object() takes no arguments” error when you run your code. In this guide, we…
Python TypeError: ‘float’ object cannot be interpreted as an integer Solution
Python has two data types that represent numbers: floats and integers. These data types have distinct properties. If you try to use a float with a function that only supports integers, like the range() function, you’ll encounter the “TypeError: ‘float’…
Python TypeError: ‘method’ object is not subscriptable Solution
Arguments in Python methods must be specified within parentheses. This is because functions and methods both use parentheses to tell if they are being called. If you use square brackets to call a method, you’ll encounter an “TypeError: ‘method’ object…
Python TypeError: can only join an iterable Solution
The join() method lets you transform an iterable object such as a list into a string. It is the opposite of the split() method. If you try to use this method to join a value that is not an iterable…
Python SyntaxError: can’t assign to function call Solution
To assign the result of a function to a variable, you must specify the variable name, followed by an equals sign, followed by the function you want to call. If you do not follow this order, you’ll encounter a “SyntaxError:…
Python typeerror: ‘list’ object is not callable Solution
When you try to access items in a list using curly brackets ( () ), Python returns an error. This is because Python thinks that you are trying to call a function. In this guide, we talk about the Python…
Python TypeError: ‘builtin_function_or_method’ object is not subscriptable Solution
To call a built-in function, you need to use parentheses. Parentheses distinguish function calls from other operations that can be performed on some objects, like indexing. If you try to use square brackets to call a built-in function, you’ll encounter…
Python TypeError: ‘NoneType’ object is not subscriptable Solution
Python objects with the value None cannot be accessed using indexing. This is because None values do not contain data with index numbers. If you try to access an item from a None value using indexing, you encounter a “TypeError:…
Python TypeError: list indices must be integers, not tuple Solution
Lists are indexed using numbers. This means if you want to access an item from a list, you have to refer to its index position. If you specify a tuple as a list index value, you encounter the “TypeError: list…
Python: Read Text File into List
Storing data in files lets you keep a record of the data with which a program is working. This means you don’t have to generate data over again when working with a program. You just read that data from a…
Python TypeError: object of type ‘NoneType’ has no len() Solution
The len() method only works on iterable objects such as strings, lists, and dictionaries. This is because iterable objects contain sequences of values. If you try to use the len() method on a None value, you’ll encounter the error “TypeError:…
Python TypeError: can only concatenate list (not “int”) to list Solution
Lists can be concatenated to other lists. This means you can add the contents of one list to another list. Values with other data types, such as integers, cannot be concatenated to a list. If you try to concatenate an…
Python typeerror: ‘float’ object is not subscriptable Solution
Values inside a float cannot be accessed using indexing syntax. This means that you cannot retrieve an individual number from a float. Otherwise, you’ll encounter a “typeerror: ‘float’ object is not subscriptable” in your program. In this guide, we talk…
Python Interpreters: A Step-By-Step Guide
Python is super accessible to learn because Python Interpreters exist online without having to ensure you have the correct version of Python installed on your machine. In this article, we talk about what the Python Interpreter is and list some…
Python TypeError: ‘float’ object is not callable Solution
Floating-point values are not callable. This is because floating points store numerical values. They are not functions that return a particular value when called. If you try to call a floating-point value as if it were a function, you encounter…
Python TypeError: can’t multiply sequence by non-int of type ‘str’ Solution
You can multiply two numbers together in Python. You can also multiply a number by a string. This returns a sequence of a string that repeats a specific number of times. If you try to multiply a string by another…
Python valueerror: could not convert string to float Solution
Python can only convert a valid numerical value to a floating point value. If you try to convert a value that contains a comma, spaces, or certain characters, you encounter an error that says “valueerror: could not convert string to…
Python TypeError: ‘NoneType’ object has no attribute ‘append’ Solution
The Python append() method returns a None value. This is because appending an item to a list updates an existing list. It does not create a new one. If you try to assign the result of the append() method to…
Python: How to Round to Two Decimal Places
How do you round a value to two decimal places in Python? That’s an excellent question. Luckily for you, Python offers a few functions that let you round numbers. Rounding numbers to two decimal places is common. Money only uses…
Python isalpha, isnumeric, and isAlnum: A Guide
The Python isalpha() method returns true if a string only contains letters. Python isnumeric() returns true if all characters in a string are numbers. Python isalnum() only returns true if a string contains alphanumeric characters, without symbols. When you’re working…
What Does %s Mean in Python?
Do you want to add a value into a Python string? You need not look further than the %s operator. This operator lets you format a value inside a string. The %s syntax is more elegant than the concatenation operator…
Python SyntaxError: unexpected character after line continuation character Solution
The Python line continuation character lets you continue a line of code on a new line in your program. The line continuation character cannot be followed by any value. If you specify a character or statement after a line continuation…
Python Array: A Step-By-Step Guide
Python arrays are a data structure like lists. They contain a number of objects that can be of different data types. In addition, Python arrays can be iterated and have a number of built-in functions to handle them. Python has…