Replacing the last character in a field

830
2
Jump to solution
04-25-2018 02:44 AM
MarkHenigan
New Contributor

Hi,

I have a string field in attribute table with values like:

125.15.

1.589.

I need to replace the last character "." by "1" in the field calculator with python parser, so my values will be like:

125.151

1.5891

How can I do this?

Thanks

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

like this (python parser)

# ---- example ----
a = '125.15.'

"{}1".format(a[:-1])

'125.151'

# ---- for the field calculator ----

"{}1".format(!YourFieldNameHere![:-1])‍‍‍‍‍‍‍‍‍‍

View solution in original post

2 Replies
DanPatterson_Retired
MVP Emeritus

like this (python parser)

# ---- example ----
a = '125.15.'

"{}1".format(a[:-1])

'125.151'

# ---- for the field calculator ----

"{}1".format(!YourFieldNameHere![:-1])‍‍‍‍‍‍‍‍‍‍
MarkHenigan
New Contributor

Perfect!!

Thanks a lot Dan

0 Kudos