def almostIncreasingSequence(sequence):
x = sequence
for i in range(len(x)):
sequence = x
cont = 0
y = False
sequence.remove(sequence[i])
for j in range(len(sequence)):
try:
if sequence[j] < sequence[j+1]:
cont += 1
if cont == (len(sequence)-2):
y = True
except:
if sequence[-1] > sequence[-2]:
cont += 1
if cont == len(sequence)-1:
if y == True:
pass
else:
y = False
return y
I have a problem with this code, because when I use remove in the sequence list, besides removing the element from the sequence list, but also removing the same element from the x list, I would like to know how to fix this, or if it is not possible using the remove, if it is possible to have a variable to save the sequence list without it being altered.