def solution(num: int) -> int:
nums = list(str(num))
b = ['7', '9', '7']
for i in range(len(nums)):
if nums[i : i + 3] == b:
nums.pop(i+1)
return int(''.join(nums))
for i,n in enumerate(str(num)):
if n != "9" :
new_list.append(n)
elif n=="9" and (str(num)[i - 1] != "7" or str(num)[i + 1] != "7"):
new_list.append(n)
return int("".join(new_list))
def solution(num: int) -> int:
s = list(str(num))
l = len(s)
for i in range(l):
if s[i] == '7':
try:
if s[i+1] == '9' and s[i+2] == '7':
s.pop(i+1)
except IndexError :
return int(''.join(s))
return num
def solution(num: int)-> int:
# your code here
st = str(num)
li = list(st)
for i in range(len(li)):
if li[i:i+3]==["7","9","7"]:
li.pop(i+1)
return int("".join(li))
assert solution(797) == 77
assert solution(7979797) == 7777
assert solution(165561786121789797) == 16556178612178977