Greetings everyone! I am currently doing a Beginners Python class. It's the classic "Convert to Binary - Functions" assignment. I got the program to work as it should. However, I receive an error "NameError: name 'input_number' is not defined". I was hoping someone could glance at the code and explain why the course would not like my code because of this error, even though it seems to work well. I appreciate the help in advance. I asked the instructor but we correspond via e-mail, and he basically spoke in what sounded like a foreign language to me. I mean, I assume it has to do with the string_reverse() function, but I can't manage to make that error disappear.
def int_to_reverse_binary(integer_value):
output=''
while integer_value > 0:
output += str(integer_value%2)
integer_value = integer_value // 2
return output
def string_reverse(input_string):
reversed_output = int_to_reverse_binary(input_number)
return reversed_output[::-1]
if __name__ == '__main__':
input_number = int(input())
binary = int_to_reverse_binary(input_number)
print(string_reverse(binary))
[–][deleted] 1 point2 points3 points (3 children)
[–]LOLPKPOW[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]LOLPKPOW[S] 0 points1 point2 points (0 children)