[Solved] How are the letters deleted from this “Vowel eater”?


For continue, it essentially skips to the end of the loop and starts the next loop, so following through your loop:

  1. Look at the current letter
  2. If the current letter is a vowel, then continue. (This skips to the next letter in the loop, so the line print(letter) will not be run).
  3. If the current letter is not a vowel, it reaches the else statement and prints the letter.

This means that in the end, the program only prints letters which are not vowels, as whenever a vowel is reached continue is run meaning it skips to the next letter (so the letter is not printed).

Side note: even if you didn’t use continue in each elif statement, and used maybe pass instead (which is just a “blank” instruction), the code would still work as by entering one of the if or elif options in the if statement, it means that it won’t run any of the other elif or elses afterwards, so the print(letter) wouldn’t be called either way. A better way to show the use of continue would be to place the print(letter) outside and after the if statement.

0

solved How are the letters deleted from this “Vowel eater”?