- 1

How to delete the digits?

A number 4529, I want to delete 2 digits, and let the result become minimum. For example, 4529-->29, 4529-->52, 29 is minimum, which is what I want.

6th Apr 2020, 5:11 PM
linzuxuan
linzuxuan - avatar
4 ответов
+ 2
a=int(input()) mins=a%100 while a>9 : if mins>(a%100) : mins=a%100 a=a//10 print(mins) For Input: 12345 Output: 12 because in 12345, 12 is minimum For input 4528, output is 28 Is this you are looking?
6th Apr 2020, 6:01 PM
Jayakrishna 🇮🇳
+ 2
mynum = 4529 strmynum = str(mynum) mylist = [] for x in range(len(strmynum)-1): mylist.append(int(strmynum[x:x+2])) print(min(mylist))
6th Apr 2020, 6:10 PM
rodwynnejones
rodwynnejones - avatar
0
Does anyone understand what linzuxuan wants? I'm don't understood... rodwynnejones 's code is best decision
6th Apr 2020, 7:21 PM
Valerii Mamontov
Valerii Mamontov - avatar
6th Apr 2020, 5:11 PM
linzuxuan
linzuxuan - avatar