Odoo Help

0
3 Answers
3
Avatar

Anil R. Kesariya (AKE)

--Anil R. Kesariya (AKE)--
6204
| 7 6 8
Rajkot, India
--Anil R. Kesariya (AKE)--

Odoo Techno Functional Expert

* Engaged with odoo since May - 2012.

* Customise existing module or develop new module base on customer requirement.

* Played key developer role in many past and running projects.

* Expert in requirement gathering of business and transforming requirement into odoo platform.

* Major expertise in core modules, database, report development and theme development.

* Integration expert.


Linkedin  : https://in.linkedin.com/in/anil-kesariya-97b20a66


Anil R. Kesariya (AKE)
2/3/15, 7:53 AM

Hello vadivel,

I agree with Stephen Ans. this is not odoo question this is related to python code. you can right python code to replace your later.

Here you Go! I have written sample method which will swap your latter in string. this will not only work for your number 3 and number 1.

I have written dynamic progrma which will ask for user Input which latter to be replace in string.

def swap_letter( a, b, dt):

    left_val_idx = []
    right_val_idx = []
    for d in dt:
        if d == a:
            left_val_idx.append(dt.index(d))
        elif d == b:
            right_val_idx.append(dt.index(b))

    swaped_word = ""

    for d in dt:

        if dt.index(d) in left_val_idx:
            swaped_word += b
        elif dt.index(d) in right_val_idx:
            swaped_word += a
        else:
            swaped_word += d

    return swaped_word

data = "686934543222133457768"

#Pass your two latter to be swap in string/word and your string as argument This will work for any case.

swap_data = swap_letter("8","9", data)

print "Swap DData ::",swap_data

Hope this will help.

Regards,

Anil.

3
Avatar

Vasanth

--Vasanth--

3868
| 5 3 8
Pondicherry, India
--Vasanth--
Vasanth
2/3/15, 6:42 AM

Hi vadivel..

      There are some ways to swap characters.i give you some examples below:

 

1.           temp = "6361"
              print temp[2:]+ temp [:2]

2.           s="6361"
              swap_seq="0301"
              swapped=''.join([s[int(i)] for i in swap_seq])
              print swapped

 

Hope this will help you

2
Avatar

Stephen Mack

--Stephen Mack--

5283
| 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
2/3/15, 6:30 AM

These really are not Odoo questions, they are Python questions.  You should consider searching and posting these type of questions on stackoverflow.com.

There are a lot of smart programmers willing to help over there.

Ask a Question
Writer
Keep Informed
1 follower(s)
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.

Register
Odoo Training Center

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

Test it now