Finden Sie die größten dreistelligen Zahlen-Sie-within-a-Number

#!/usr/bin/env python

num = input("Enter the number : ")

if len(num) == 3:
    print(f"Largest digit is : {num}")
    exit(0)
elif len(num) < 3:
    print(-1)
    exit(0)

maxans = int((num[0].replace("0", "")))*100 + int((num[1].replace("0", "")))*10 + int((num[2].replace("0", "")))
prev = maxans

for i in range(3, 6):
    cur = (prev%100)*10 + int((num[i].replace("0", "")))
    maxans = max(maxans, cur)
    prev = cur

print(f"The Largest num = : {maxans}")
Himanshu Ranjan Singh