I can not figure out why my code is not working,
key_one= raw_input("Enter key (0 <= key <= 127): ")
if key_one in range(128):
bin_key_one=bin(key_one)[2:]
print bin_key_one
else:
print "You have to enter key (0 <= key <= 127)"
when i enter a number between 0 and 127, it keeps on going to the else!
can some one tell me why?
raw_inputwill return a string, so yourifcomparison fails (you’re comparing an int with a string). Try casting: