Odoo Help


How to get a first character from a string?

on 1/31/15, 1:16 AM 15,720 views

Hi Friends,

I have to split a character from string.

For Example,If Name is like Sai Sathi Bawan,I have to split a first character from these strings as SSB and have to join these characters.How can we achieve this?Please help me in this friends.Thanks in advance




Stephen Mack

--Stephen Mack--

| 8 8 9
Santiago, Chile
--Stephen Mack--

Some people call me a karma whore, I only ask for 10 points if you like my answer and 15 if I happen to get it correct.

Stephen Mack
On 1/31/15, 1:21 AM

In python you can limit your string by using the VARIABLE[:NUMBER] format.

First character of a string


First five characters of a string


Last seven characters of a string


So what you need is highlighted in bold

my_name = "Sai sathi bawan"
my_initals = ''.join([s[:1] for s in my_name.split(' ')])

Output: Ssb

To force Upper Case...

my_name = "Sai sathi bawan"
my_initals = ''.join([s[:1].upper() for s in my_name.split(' ')])

Output: SSB

updated response

Stephen Mack
on 1/31/15, 2:00 AM

Thank you so much Stephen Mack for your response.Its mean a lot to me

on 1/31/15, 2:27 AM

Sure no problem. Have a good day.

Stephen Mack
on 1/31/15, 2:30 AM

Usefull Example Stephen Mack...

on 2/2/15, 8:48 AM

One more help.Mack i want to swap characters 6361 result as 6163 How it is possible??

on 2/3/15, 5:08 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/31/15, 1:16 AM
Seen: 15720 times
Last updated: 3/16/15, 8:10 AM