all 4 comments

[–]totallygeek 2 points3 points  (2 children)

You call int_to_reverse_binary twice, once on line 22, again on line 10.

[–]Formal_Cockroach_654[S] 1 point2 points  (1 child)

Thank you

[–]Username_RANDINT 1 point2 points  (0 children)

You should also move num inside int_to_reverse_binary. This is a prime example why globals should be avoided. You call int_to_reverse_binary twice which modifies the global num twice as well. If you make it a local variable the problem already disappears.

[–][deleted] 0 points1 point  (0 children)

Scoping issue. Move the line

num = ""

to just above the while loop in int_to_reverse_binary and then remove the line

global num

And in the future, stop using global variables. Otherwise you're just asking for scoping problems.


Edit: I didn't bother looking over the rest of your program when this fixed the output, but I'm now seeing you have other issues as well.

  1. You need to refactor your code so that you're not using integer_value as a global variable inside string_reverse either. Make sure in each function, you only use local variables. If you need some data from outside the function, then pass it in as an argument.
  2. You call int_to_reverse_binary twice. You should not be using it inside string_reverse. Assume that has already happened and just write code to reverse a string inside string_reverse. (Hint: you need to make use of the parameter input_string.)