The objective was the following to be solved in Python:
Given a string, def a function that returns another string with the vowels (upper or lowercase) replaced by 0,1,2,3,4 respectively.
Example input:
"bB nN aei ou AEIOU"
Desired Output:
"bB nN 012 34 01234"
This is in fact quite trivial and can be solved in several ways, one way may be this:
def crypt(s):
vow = ["a","e","i","o","u"]
stringL = []
for x in s:
if x in vow or x.lower() in vow:
stringL.append(str(vow.index(x.lower())))
else:
stringL.append(x)
return "".join(stringL)
I was told this was over-complicated for such a simple task, that code like this would be difficult to debug etc.
Would you consider this approach a "bad" one, which way would you have gone instead, is it unclear?