Select to view content in your preferred language

Calculate Field with Python

726
3
Jump to solution
02-25-2022 02:04 AM
KalSsin
Regular Contributor

Dear Community~~질문1.png

def abbreviate(x):
words = x.split()
letters = [word[:3] for word in words]
return "".join(letters)

 

 

I want to make it like the picture below.
What should I do?

질문2.png

 

Thank You~~

0 Kudos
1 Solution

Accepted Solutions
DuncanHornby
MVP Notable Contributor

A solution is this:

def abbreviate(x):
    words = x.split()
    letters = [word[:3] + " / " for word in words]
    text = "".join(letters)
    text = text[:-3] # Remove last slash
    return text

View solution in original post

3 Replies
DuncanHornby
MVP Notable Contributor

A solution is this:

def abbreviate(x):
    words = x.split()
    letters = [word[:3] + " / " for word in words]
    text = "".join(letters)
    text = text[:-3] # Remove last slash
    return text
KalSsin
Regular Contributor

It's incredible.~~~~

 

Thank you so m~~~~uch.

0 Kudos
JayantaPoddar
MVP Esteemed Contributor

Just the following expression should work. No Code Block required.

'/'.join([i[0:3] for i in !Name_Add1!.split(' ')])


Think Location
0 Kudos