What went wrong in my code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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.

27th Feb 2018, 1:25 PM
Asaf Ullah
Asaf Ullah - avatar
6 Answers
+ 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.
27th Feb 2018, 1:38 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 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.
27th Feb 2018, 2:05 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 1
What is the error you get, if possible post your *code link* here.
27th Feb 2018, 1:33 PM
Ravi Chandra Enaganti
Ravi Chandra Enaganti - avatar
27th Feb 2018, 1:58 PM
Asaf Ullah
Asaf Ullah - avatar
0
I get an output till Enter the base:,and the rest of the code just does not work
27th Feb 2018, 1:35 PM
Asaf Ullah
Asaf Ullah - avatar
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.
27th Feb 2018, 2:07 PM
Asaf Ullah
Asaf Ullah - avatar