I'm writing my assignment in python, a simple binary calculation program and for some reason when I am executing the program, I get a syntax error, which I don't understand as I was told the ':' at the end of a for loop or while loop for that matter is essential, just like it would be for an if/elif/else statement.
The code for the whole section of that area of code is:
for m in range(binaryCountingVariable):
countingDecimalVariable = m + 1
countingBinaryVariable = ''
while countingDecimalVariable != 0:
countingDecimalRemainder = countingDecimalVariable % 2
countingBinaryVariable = countingBinaryVariable + str(countingDecimalRemainder)
countingDecimalVariable = countingDecimalVariable // 2
print('Decimal:', i, '= Binary:', countingBinaryVariable[::-1], sep='')
Aucun commentaire:
Enregistrer un commentaire