I'm running into this error quite a bit and I can't quite seem to understand why this error keeps popping up.
def addnumbers(number1, number2, base):
sum = bin(int(number1,base)+int(number2,base))
print(sum)
return sum
assert addnumbers("100011", "110011", 2) == "1010110"
assert addnumbers("4013", "4217", 8) == "10232"
addnumbers("100011","110011",2)
So I have this code that is a simple way of adding strings together and returning them in their base form, and right now I'm working on the hexadecimal part first. So the first assert line.
0b1010110
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-8-1102c03eff64> in <module>
17 return sum
18
---> 19 assert addnumbers("100011", "110011", 2) == "1010110"
20 assert addnumbers("4013", "4217", 8) == "10232"
21 addnumbers("100011","110011",2)
AssertionError:
However, it returns with an error and a blank assertion error, and I'm not really sure where to start fixing my code when I don't really know how to fix the first assert line and giving me a blank error message. If anyone could give me any guidance to why the assertion error returns a blank that would be very much appreciated!
Aucun commentaire:
Enregistrer un commentaire