Odoo Help


This community 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.


How to get a first character from a string?

on 1/31/15, 1:16 AM 818 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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


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