When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer!

OK so I was having problems with my code,

and this error message comes up

Welcome to Andres’s Calculator!
Value: 5 stored in the Register: 1.
Value: 10 stored in the Register: 2.
Invalid OPCODE
Invalid OPCODE
Invalid OPCODE
Invalid OPCODE
Traceback (most recent call last):
File “calculator.py”, line 168, in
your_calculator.binary_reader(“10000100000000000000000000000000”)
File “calculator.py”, line 129, in binary_reader
self.get_last_calculation()
File “calculator.py”, line 112, in get_last_calculation
last_value = f"Last result = {int(self.history_registers[self.temp_history_index], 2)}"
TypeError: int() can’t convert non-string with explicit base

It seems that int(firstArgument, 2) requires that first argument to be a string,
but the stuff in self.history_registers start out being integers:
In the __init__ function, you have self.history_registers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

You can fix this by only using that int(firstArgument, 2) if the first argument is a string.
So instead of

last_value = f"Last result = {int(self.history_registers[self.temp_history_index], 2)}"

you could put something like

from_register = self.history_registers[self.temp_history_index]
if isinstance(from_register, str):
last_value = f"Last result = {int(from_register, 2)}"
else:
last_value = f"Last result = {from_register}"

Welcome to Andres’s Calculator!
The number 5 was stored to register 1
The number 10 was stored to register 2
Calculated Result: 5
Calculated Result: 5
Calculated Result: 0
Divison by 0 error: 5/0.
Calculated Result: 0
Traceback (most recent call last):
File “calculator.py”, line 175, in
your_calculator.binary_reader(“10000100000000000000000000000000”)
File “calculator.py”, line 136, in binary_reader
self.get_last_calculation()
File “calculator.py”, line 112, in get_last_calculation
last_value = f"The last calculated value was: {int(self.history_registers[self.temp_history_index], 2)}"
TypeError: int() can’t convert non-string with explicit base

so I got this solution but I was wondering if its correct

Welcome to Andres’s Calculator!
The number 5 was stored to register 1
The number 10 was stored to register 2
Calculated Result: 5
Calculated Result: 5
Calculated Result: 0
Divison by 0 error: 5/0.
Calculated Result: 0
Last result = 0
Last result = 0
Last result = 0