+ 1

Can someone help me fix this code??

Tis code is suppose to take a number like "0002" and the user_num as to be equal "2". Basically the code takes all zeros that don't do any difference to it. user_input = '0002' zero_cuter = 0 user_num = "" if user_input [zero_cuter] == '0': zero_cuter += 1 elif user_input != '0': max_couter_cuter = len(user_input) min_couter_cuter = zero_cuter while min_couter_cuter <= max_couter_cuter: user_num = user_input[min_couter_cuter ] min_couter_cuter += 1 print (user_num) print (user_num ) print ("...") https://code.sololearn.com/c0AvmvKb2I96/?ref=app

13th Jul 2019, 2:42 PM
David João Gonçalves
David João Gonçalves - avatar
2 odpowiedzi
+ 4
user_input = '0002' while user_input[0] == '0': user_input = user_input[1:] user_num = user_input; print(user_num)
13th Jul 2019, 4:53 PM
Om Kumar
Om Kumar - avatar
+ 1
Thanks it works I didn't know that you could take out numbers from a list...
13th Jul 2019, 6:59 PM
David João Gonçalves
David João Gonçalves - avatar