Hello,
I thought this is simple but i cant find way, how to remove the LAST character in a list if it’s not a NUMBER?
thanks in advance
Hello,
I thought this is simple but i cant find way, how to remove the LAST character in a list if it’s not a NUMBER?
thanks in advance
Would something as follows be what you was after?
Code:
#Created By Brendan Cassidy
output=
for a in IN[0]:
if a[-1].isdigit():output.append(a)
else:
output.append(a[:-1])OUT=output
Image of code:
@lucifer Are you after getting rid of all characters at the end until it becomes a number or just the last character if it isnt a number?
If you want to get rid of just the last digit then my first post will work, if not the below may be a better solution
Code(image):
Code:
#Created By Brendan Cassidy
def digitcheck(input):
templist=
count=0
for a in input:
if a.isdigit():
templist.append(count)
else:
templist.append(0)
count=count+1
return max(templist)+1output=
for a in IN[0]:
output.append(a[:digitcheck(a)])OUT=output
remove just the last character if it’s a letter Thanks @Brendan_Cassidy
Is there also a solution if the last character is a special character?
In example a _ (underscore)?
NB
I am happy with ANY solution how to remove the last character if it is a _ (underscore).