answersLogoWhite

0


Best Answer

It means you are trying to perform an operation with an incompatible type. Without knowing what code caused the error it's impossible to give an explicit answer, however a typical example of a type error is that you've attempted to perform an arithmetic operation upon a non-numeric value such as a string. E.g., "hello world" * 42 makes no sense in the real world because "hello world" is a non-numeric value and is therefore incompatible with the multiply operator.

Type errors are common when working with unchecked input. That is, you expect the user to enter a number but they enter a letter instead. If you don't test for this, errors are the inevitable consequence.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

8y ago

This error arises when attempting to perform an operation or function on an object of inappropriate type.

For example


s = "this is a string"

s - 1


Traceback (most recent call last):

File "/answers-example.py", line 2, in

s - 1

TypeError: unsupported operand type(s) for -: 'str' and 'int'


Subtracting 1 (an int) from a string (str) is not a valid operation.


This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is a type error in Python and what am I doing wrong?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What combination of factors produces the smallest risk of a type 1 error?

A combination of factors increase the risk of a Type 1 error. Giving the wrong amount or wrong diagnosis for a wrong drug would certainly increase an error.


How much do wrong prited quarters cost?

It depends on the type of error. Look for an inline reference to error coins.


Is there such thing as a bull python?

The ball python is only one type of Python. As I don't know which other type of python you're asking me to compare the ball python with I can't really answer your question...


Why do I always get it wrong when you have to type in the random words to post something?

Is your computer on Caps Lock? Or, are you typing the wrong words? If you are doing either of these things, your typing will result in error. Make sure that your computer isn't on Caps Lock and that you are typing the random words exactly as they appear.


How do you correct CIBIL report?

You have to raise an online dispute with CIBIL bureau by visiting their website to get the errors The bankers are responsible for the updating of CIBIL reports every month. But there are chances of mistakes while doing certain data entries. The mistakes may include the wrong account and loan type, wrong status, wrong ownership type, wrong dates, error in sanctioned amount, error in current balance and overdue amount, error in assets and many such other errors. So it is essential that you keep a check on your CIBIL report and get it corrected if you find anything wrong in it to avoid any risk in future loans. To know more on this you can also visit Creditsudhaar website.


Is a reticulated python and a regular python the same?

Reticulated pythons are one type of python. They are the biggest pythons in the world.


How do you open a Python program with MS-DOS?

open MS-DOS in the directory you have the python file in. type "python [INSERTNAMEOFSCRIPT]"


Why cant you open Pokemon indigo?

Ill bet you guys are doing it all wrong. You need to type in Budvar.pkindigo.com/login.php Dont type in www. or else youll get that stupid Error 403 sign that's been driving me CRAZY for only God knows how long.


Relationship between type 1 error and type 2 error?

In statistics, there are two types of errors for hypothesis tests: Type 1 error and Type 2 error. Type 1 error is when the null hypothesis is rejected, but actually true. It is often called alpha. An example of Type 1 error would be a "false positive" for a disease. Type 2 error is when the null hypothesis is not rejected, but actually false. It is often called beta. An example of Type 2 error would be a "false negative" for a disease. Type 1 error and Type 2 error have an inverse relationship. The larger the Type 1 error is, the smaller the Type 2 error is. The smaller the Type 2 error is, the larger the Type 2 error is. Type 1 error and Type 2 error both can be reduced if the sample size is increased.


What type is the largest python in Australia?

goanna


How do the characteristics of the burmese python envieronment effect the burmese python?

Type your answer here... they eat many animals and wildlife


What is a type of snake that starts with the letter P?

Python.