0
What went wrong in my code?
Below is a code that I wrote to complete the first challenge(converting numbers using a given base),but for some reason it isn't working,can somebody tell me what went wrong here: all_numbers="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" a=int(input("Enter the number you want to convert:")) print(a) b=int(input("Enter the base:")) print(b) k=(a//b) l=(a%b) while k<a: k=(k//b) l=(k%b) print(all_numbers[l][::-1]) I'm a newbie,so please help me out. Thanks in advance.
6 Respostas
+ 3
https://www.sololearn.com/Codes/
^Go there and click 'New Code.' Then click on editor drop-down and select 'Python.' Post your code there, save it, and send to us.
+ 3
@Asaf
Do you mind explaining exactly what your goal is with the code?
I know that your while loop is ALWAYS going to return 0 as its output because you're forcing it to divide/get remainder until it can't divide anymore, which means the remainder always will end as 0 and that'll always be the value for the array you're printing at the end.
If you explain your goal, I can help you out further.
+ 1
What is the error you get, if possible post your *code link* here.
0
I get an output till Enter the base:,and the rest of the code just does not work
0
My goal is to write a program that can convert any given number using a given base,like converting decimal numbers to binaries etc.