mkdivis07
BAN USERdef reverse_vowels(str_):
"""
Given a string, returns a string with the order of the vowels reversed but all other chars
unchanged
"""
tmp = list(str_)
positions_and_vowels = [(index, char) for index, char in enumerate(tmp) if char in 'aeiou']
positions, vowels = [x[0] for x in positions_and_vowels], [x[1] for x in positions_and_vowels]
vowels.reverse()
for index, char in zip(positions, vowels):
tmp[index] = char
print tmp
o=[]
t=[]
def shuffle_string(a):
for i in a:
if len(o) == 0:
o.append(i)
elif o[-1]!=i:
o.append(i)
j = len(t)
while j != 0:
if o[-1] != t[j-1]:
o.append(t.pop())
j-=1
else:
t.append(i)
for j in t:
for i in xrange(len(o)):
if i == 0 and o[i]!= j:
o.insert(i,j)
elif o[i]!=j and o[i+1]!=j:
o.insert(i+1,j)
print o
shuffle_string("ABCCCc")