def shortenPlus(s):
# Yer Code 'Ere Mate!
# Aye Aye cap'
new = ''
prior = ''
for x in s:
if not (x in 'aeiou' and prior.isalpha()):
new += x
prior = x
return new
print(shortenPlus("I've information vegetable, animal and mineral"))
So here's the code that I found from this thread. I am having trouble understanding how the "if not" part of the for loop works, and why we have new and prior statements.
I understand that we take a variable from the string, and if this variable is NOT in 'aeiou', and the prior container does NOT have anything from the alphabet, then you add this variable to new. But if prior is I, and x is v, it doesn't satisfy the prior criteria, and yet it still adds it to new.
This is how I'm understanding it so far. Please let me know what I'm misunderstanding!