Hi, this is my first time sharing my code here, so please don't judge :) But I really like these little challenges, thank you!
Here we go (python ftw!):
def vowel(input): vowels = ['a','e','i','o','u'] lengthes = [] lastVowel = False for c in input: if c in vowels: if not lastVowel: lengthes +=[1] else: lengthes[len(lengthes)-1] += 1 lastVowel = True else: lastVowel = False return max(lengthes) print(vowel("codewarriors"))
There is probably some room for improvement...
Have a nice day!
Hi @heidrichj you could also use the class Counter from collections package :)
from typing import Union from collections import Counter def vowel(word: str) -> Union[int, None]: letters = ('a', 'e', 'i', 'o', 'u') letters_on_word = Counter(word) for letter, quantity in letters_on_word.most_common(): if letter in letters: return quantity
Tip:
Always use tuple in a list that is "fixed" to ensure that this list will be immutable
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi,
this is my first time sharing my code here, so please don't judge :)
But I really like these little challenges, thank you!
Here we go (python ftw!):
There is probably some room for improvement...
Have a nice day!
Hi @heidrichj you could also use the class Counter from collections package :)
Tip: