RE: Code Wars Python Challenge: Vowel Count
You are viewing a single comment's thread:
List comprehensions are cool, but putting everything in one line can make code hard to debug. Starting with a more step by step approach can help validate your algorithm. I notice one of the solutions checks for upper case, but the exercise specified it was all lower case.
I've been doing a course that uses functional languages where you are discouraged from using loops. That means lots of recursion which can be inefficient in some language, but can make for elegant code.
0
0
0.000
List comprehensions are the preferred way to iterate in Python. It is considered the "Pythonic" way to do things.
For the upper() you mean the RGB to hex challenge? I noticed the test output required upper case. The solution also showed uppercase output.
From experience I know that writing the shortest code can cause issues when you need to expand functionality later. Need to consider what is best for each case. Sometimes shorter code is not necessarily more efficient. It depends a lot on optimisations done in the compiler or interpreter and they are pretty clever these days.
The one line solution for finding vowels had
in 'aeiouAEIOU'
but that went beyond the requirement.
Oh I thought you meant one of my solutions so I looked through my older posts lol.
I agree about shorter code isn't better all the time I've mentioned it in most of my posts.