Monday, 19 September 2016

python - Add the trailing characters upto the first first occurrence of a vowel to the end of the word

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

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...