2
def removeDigit(self, number: str, digit: str) -> str:4
# Initializing the last index as zero7
# iterating each number to find the occurences, \8
# and to find if the number is greater than the next element \10
for num in range(1, len(number)):12
# Handling [case 1] and [case 2]13
if number[num - 1] == digit:14
if int(number[num]) > int(number[num - 1]):15
return number[: num - 1] + number[num:]19
# If digit is the last number (last occurence) in the string [case 3]20
if number[-1] == digit:21
last_index = len(number) - 123
return number[:last_index] + number[last_index + 1 :]