Python string replace in a label

3497
3
Jump to solution
03-20-2017 12:15 PM
TimFerguson
New Contributor

I am trying to replace an ampersand with & in a label expression in ArcGIS Desktop 10.4.1

my current code is along these lines: 

define FindLable([customer]):
    return replace([customer], '&', '&')

For some reason this throws the following error: "Global name replace is not defined."

What is the correct format for this python code?

I have also tried str.replace and Replace and string.replace.

Thank you,

James

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
MatthewDobson
Occasional Contributor

James, try:

def FindLabel ( [Status] ):
 return [Status].replace('&', '&')

View solution in original post

0 Kudos
3 Replies
TimFerguson
New Contributor

For the record: I am actually using define FindLabel spelled correctly.

0 Kudos
MatthewDobson
Occasional Contributor

James, try:

def FindLabel ( [Status] ):
 return [Status].replace('&', '&')
0 Kudos
TimFerguson
New Contributor

That was it. Thank you Mathew.

0 Kudos