python code for string re-arrangement
<p>Can anyone help me with python code which  transforms the  word/string as follows  Move all consonants before the vowels - The consonants and vowels should be in the reverse order of the original. - If two equal letters come next to each other in the result (case insensitive duplicates),   drop the second letter in the source.</p>

<p>I tried this:</p>

<pre><code>def vowels(x): 
    vowel = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"] 
    if x in vowel: 
        return True 
    else: 
        return False 

def transform_word(word): 
    result = "" 
    if word is not None: 
        x = len(word) - 1 
    v = "" 
    c = "" 
    while x is not -1: 
        if (vowels(word[x])): 
            v += word[x] 
            x -= 1 
        else: 
            c += word[x] 
            x-=1 
    result = c + v 
    result = "".join(OrderedDict.fromkeys(result)) 
    return result 
</code></pre>

<p>Should work, more or less what you had concept wise, with worse far worse string concatenation.    </p>

<pre><code>def isvowel(ch):
     if ch in ["A", "E", "I", "O", "U", 'a','e','i','o','u']:
          return True
     else:
          return False

vowels = []
consonants = []

for letter in word:
    if isvowel(letter):
        vowels.append(letter)
    else:
        consonants.append(letter)
result = ''

for consonant in consonants:
    result+=consonant
for vowel in vowels:
    result+=vowel
print result
</code></pre>

python