Your checkAnswer()
function returns a tuple:
def checkAnswer(number1, number2, answer, right): if answer == number1+number2: print 'Right' right = right + 1 else: print 'Wrong' return right, answer
Here return right, answer
returns a tuple of two values. Note that it’s the comma that makes that expression a tuple; parenthesis are optional in most contexts.
You assign this return value to right
:
right = checkAnswer(number1, number2, answer, right)
making right
a tuple here.
Then when you try to add 1
to it again, the error occurs. You don’t change answer
within the function, so there is no point in returning the value here; remove it from the return
statement:
def checkAnswer(number1, number2, answer, right): if answer == number1+number2: print 'Right' right = right + 1 else: print 'Wrong' return right
Related Posts:
- django: TypeError: ‘tuple’ object is not callable
- TypeError: not all arguments converted during string formatting python
- What are “named tuples” in Python?
- “Series objects are mutable and cannot be hashed” error
- I keep getting this error for my simple python program: “TypeError: ‘float’ object cannot be interpreted as an integer”
- Python convert tuple to string
- TypeError: ‘list’ object cannot be interpreted as an integer
- Convert list to tuple in Python
- Python TypeError: not enough arguments for format string
- TypeError: unsupported operand type(s) for /: ‘str’ and ‘str’
- TypeError: unsupported operand type(s) for -: ‘list’ and ‘list’
- Python add item to the tuple
- Python: tuple indices must be integers, not str when selecting from mysql table
- Python TypeError must be str not int
- How to sort a list/tuple of lists/tuples by the element at a given index?
- Append a tuple to a list – what’s the difference between two ways?
- TypeError: ‘int’ object does not support item assignment
- TypeError: ‘int’ object does not support item assignment
- Add Variables to Tuple
- What’s the difference between lists enclosed by square brackets and parentheses in Python?
- Why is there no tuple comprehension in Python?
- Why is there no tuple comprehension in Python?
- TypeError: ‘_io.TextIOWrapper’ object is not subscriptable
- “Can’t convert ‘float’ object to str implicitly”
- Python3 Error: TypeError: Can’t convert ‘bytes’ object to str implicitly
- typeerror ‘builtin_function_or_method’ object has no attribute ‘__getitem__’
- TypeError: decoding str is not supported
- How does tuple comparison work in Python?
- pandas comparison raises TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool]
- TypeError: can only concatenate tuple (not “str”) to tuple Error
- TypeError: module.__init__() takes at most 2 arguments (3 given)
- TypeError: coercing to Unicode: need string or buffer, int found
- Python cant convert ‘list’ object to str error [closed]
- creating sets of tuples in python
- “Can’t convert ‘float’ object to str implicitly”
- Can I put a tuple into an array in python?
- str.translate gives TypeError – Translate takes one argument (2 given), worked in Python 2
- Python convert tuple to string
- Does Python have an immutable list?
- TypeError: ‘NoneType’ object has no attribute ‘__getitem__’
- TypeError: coercing to Unicode: need string or buffer
- ValueError: invalid literal for int() with base 10: ”
- Print string to text file
- How can I parse a YAML file in Python
- Cannot find module cv2 when using OpenCV
- Maximum and Minimum values for ints
- How is Anaconda related to Python?
- What is the python keyword “with” used for? [duplicate]
- What is the purpose of meshgrid in Python / NumPy?
- How to add to the PYTHONPATH in Windows, so it finds my modules/packages?
- FileNotFoundError: [WinError 2] The system cannot find the file specified:
- Importing class from another file [duplicate]
- Pandas group-by and sum
- Python List vs. Array – when to use?
- How to terminate a script?
- numpy array concatenate: “ValueError: all the input arrays must have same number of dimensions”
- csv.Error: iterator should return strings, not bytes
- SyntaxError: non-default argument follows default argument
- socket.error: [Errno 48] Address already in use
- Creating a basic auto clicker in python
- What’s the difference between torch.stack() and torch.cat() functions?
- How do I remove all packages installed by PIP?
- ValueError: need more than 1 value to unpack python
- What is the best way to exit a function (which has no return value) in python before the function ends (e.g. a check fails)?
- How to disable Python warnings?
- LinAlgError: Last 2 dimensions of the array must be square
- How to get data from SNMP with python?
- What does axis in pandas mean?
- Dynamically growing a python array when assigning to it
- module ‘pandas’ has no attribute ‘rolling_mean’
- Displaying better error message than “No JSON object could be decoded”
- List attributes of an object [duplicate]
- How can I set the aspect ratio in matplotlib?
- In Python how should I test if a variable is None, True or False
- Pythonic way to iterate through a range starting at 1
- Convert from CSV to array in Python
- AttributeError: ‘list’ object has no attribute ‘replace’ when trying to remove character
- ValueError: unsupported pickle protocol: 3, python2 pickle can not load the file dumped by python 3 pickle?
- Relative paths in Python
- TypeError: ‘bool’ object is not callable
- How do I maximize the display screen in PyGame?
- Why does PyQt crashes without information? (exit code 0xC0000409)
- How to put the legend out of the plot
- Python string prints as [u’String’]
- How can I check the extension of a file?
- Matplotlib: TypeError: can’t multiply sequence by non-int of type ‘numpy.float64’
- NameError: global name ‘unicode’ is not defined – in Python 3
- Create nice column output in python
- TypeError: unsupported operand type(s) for +=: ‘int’ and ‘list’
- TypeError: int() argument must be a string, a bytes-like object or a number, not ‘list’
- Histogram plotting “AttributeError: max must be larger than min in range parameter.”
- plot a circle with pyplot
- TypeError: super() takes at least 1 argument (0 given) error is specific to any python version?
- ValueError: cannot switch from manual field specification to automatic field numbering
- TemplateDoesNotExist at /
- How do I update a Python package?
- Using strip() to clean up a string
- Selenium “Unable to find a matching set of capabilities” despite driver being in /usr/local/bin
- Flask Value error view function did not return a response [duplicate]
- AttributeError: ‘Series’ object has no attribute ‘split’ error in sending emails