0

I don't think the heading quite explained it sufficiently.

Basically I have a list containing all of the vowels and another list containing the characters that make up the word.

I need to take the list containing the word and take all of the characters up to the first vowel and add them onto the end in order.

What I can't wrap my head around is how to do it, I had two ideas:

for characters in word:
     if(character != vowel):
         vCount += 1
     else:
         break
     break

for i in range(vCount):
     print(i)
     wList.append(wList.pop(i))

And another that was basically the same but every time it saw it wasn't a vowel it pop'd it out. The obvious issue I didn't see with these initially is that 'vowel' isn't just a singular entity, character doesn't equal a, pop, character doesn't equal e, pop, etc etc. Or in the case of vCount, it just got far longer than the actual length of wList.

Anyone have a thought on how to solve this?

EDIT: Sorry, that wasnt clear:

cat -> atc

bear -> earb

Bishwas Mishra
  • 1,235
  • 1
  • 12
  • 25
DanB
  • 1
  • 3
  • Could you please edit some sample input and output into your question for a bit more clarity? – miradulo Mar 05 '17 at 01:46
  • What about `if(!character in ('a', 'e', 'i', 'o', 'u'))`? [See this question](http://stackoverflow.com/questions/20226110/detecting-vowels-vs-consonants-in-python). – Spencer Wieczorek Mar 05 '17 at 01:47
  • If vowel is a list, then `character != vowel` compares a character to a list and this will never be true. Also, When popping from `wList` *removes* the character from `wList` which is probably not what you want. Try changing line 2 to `if (character not in vowel)` and instead of the second for loop, change it to `wList = word + word[:vCount]`. This will work so long as word has at least one vowel. If not, you will need to handle additionally. – user650654 Mar 05 '17 at 03:05

1 Answers1

0

I hope the code is self-explanatory:

vowel = 'aeiou'
my_word = 'education'
vowel_list = vowel.split()
my_word_list = my_word.split()
for index, character in enumerate(my_word):
    # Loop through the items in your my_word_list
    if character in vowel_list:
         print my_word_list[index:] + my_word_list[:index]

Input1: education

Output1: education

Input2: knowledge

Output2: owledgekn

Bishwas Mishra
  • 1,235
  • 1
  • 12
  • 25