Hi there, I'm in the process of learning Python, and need some help deciphering the reason why the following code doesn't work:
import sys, string def dec2bin(decNum): # validate the input as a postive integer number for char in decNum: if str(char).isdigit() == False: print "Not a postive integer number given when calling the dec2bin function." sys.exit() bin = "" # initialize the new binary result (as a string) num = int(decNum) if num == 0: # take care of the zero case bin = "0" while int(num) != 0: # the rest of the cases nextBin = int(num) % 2 # check if this column should be a 0 or 1 bin = str(nextBin) + bin # add the result to the front of the result string int(num) = int(num) / 2 # this is integer division, so we truncate the decimal part return bin # return the binary result # testing x = "13" print dec2bin(x) I get the following error: > File "convert.py", line 42 > int(num) = int(num) / 2 # this is integer division, so > we truncate the decimal part > SyntaxError: can't assign to function call Any help anyone can provide would be greatly appreciated. Dan _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor