BEstyle 2022. 11. 4. 13:19

DESCRIPTION:

Task

Given an integer n, find the maximal number you can obtain by deleting exactly one digit of the given number.

Example

For n = 152, the output should be 52;

For n = 1001, the output should be 101.

Input/Output

  • [input] integer n
  • Constraints: 10 ≤ n ≤ 1000000.
  • [output] an integer

def delete_digit(n):
    print(n)
    max=0
    n=str(n)
    for i in range(len(n)):
        if max<=(numEx(n,i)):
            max=numEx(n,i)
    return max
def numEx(n,i):
    return int(n[0:i]+n[i+1::])