defis_vowel(letter):return letter in ['a','e','i','o','u','y']defscore_words(words): score =0for word in words: num_vowels =0for letter in word:ifis_vowel(letter): num_vowels +=1if num_vowels %2==0: score +=2else: score +=1# Before Debugging: ++scorereturn scoren =int(input())words =input().split()print(score_words(words))
Default Arguments
classEvenStream(object):def__init__(self): self.current =0defget_next(self): to_return = self.current self.current +=2return to_returnclassOddStream(object):def__init__(self): self.current =1defget_next(self): to_return = self.current self.current +=2return to_returndef print_from_stream(n, stream=None): # Because python's default arguments are evaluated only once and used repeatedly everytime the function is called
if stream ==None:# After Debugging stream =EvenStream()# After Debuggingfor _ inrange(n):print(stream.get_next())queries =int(input())for _ inrange(queries): stream_name, n =input().split() n =int(n)if stream_name =="even":print_from_stream(n)else:print_from_stream(n, OddStream())