top of page

Vowel Exchange

  • Writer: VC Healy
    VC Healy
  • Jul 29, 2020
  • 1 min read

Another cracker from PyBites. Count the number of vowels in a piece of text and exchange them for an asterisk. ( Screenshot truncated)


The counting in this one took me some time to get my head around. For some reason, the initial function was always counting the wrong amount of vowels but exchanged every vowel. Then when it was counting the number of vowels correctly, a couple of the uppercase vowels were not being exchanged.


I decided to separate the two tasks into separate methods. The counter easily lent itself to a comprehension and I left the exchange of vowels with a loop.

The tests required the exchanged text to still hold the same case for each letter but the comparison against vowels was limited to lower case vowels. This required changing the case of each letter for the comparison but retain the original case for the final exchanged file.



 
 
 

Comments


© 2020 by Vincent Healy. Proudly created with Wix.com

bottom of page