Решение на doge от Димитър Желев

Обратно към всички решения

Към профила на Димитър Желев

Резултати

  • 10 точки от тестове
  • 1 отнета точка
  • 9 точки общо
  • 15 успешни тест(а)
  • 0 неуспешни тест(а)

Код

def wow_such_much(start, end):
"""replace numbers from start to end dividable by 3,5,15"""
result = []
for num in range(start, end):
element = ''
if num % 3 == 0:
element += 'such'
if num % 5 == 0:
element += 'much'
if element == '':
element += str(num)
result.append(element)
return result
def count_doge_words(sentence):
"""count parasite words from sentence"""
words = ('wow', 'lol', 'so', 'such', 'much', 'very')
counter = 0
for word in sentence.split():
if word in words:
counter += 1
return counter

Лог от изпълнението

...............
----------------------------------------------------------------------
Ran 15 tests in 0.010s

OK

История (3 версии и 4 коментара)

Димитър обнови решението на 07.03.2014 12:12 (преди около 10 години)

+def wow_such_much(start, end):
+ """wow_such_much(start, end) -> list"""
+ result = []
+ for num in range(start, end):
+ element = ''
+ if num % 3 == 0:
+ element += 'such'
+ if num % 5 == 0:
+ element += 'much'
+ if element == '':
+ element += str(num)
+ result.append(element)
+ return result
+
+def count_doge_words( sentence ):
+ """remove parasite words from sentence"""
+ words = ('wow', 'lol', 'so', 'such', 'much', 'very')
+ counter = 0
+ for word in sentence.split(' '):
+ if word in words:
+ counter += 1
+ return counter

Димитър обнови решението на 07.03.2014 12:13 (преди около 10 години)

def wow_such_much(start, end):
"""wow_such_much(start, end) -> list"""
result = []
for num in range(start, end):
element = ''
if num % 3 == 0:
element += 'such'
if num % 5 == 0:
element += 'much'
if element == '':
element += str(num)
result.append(element)
return result
def count_doge_words( sentence ):
- """remove parasite words from sentence"""
+ """count parasite words from sentence"""
words = ('wow', 'lol', 'so', 'such', 'much', 'very')
counter = 0
for word in sentence.split(' '):
if word in words:
counter += 1
return counter

Супер, но смятам, че в случая нямаш нужда от docstring-овете, а и този на първата функцията не е много описателен.

П.П. split по подразбиране използва интервала за разделител и не е нужно да го подаваш като аргумент :smile:

Димитър обнови решението на 07.03.2014 18:13 (преди около 10 години)

def wow_such_much(start, end):
- """wow_such_much(start, end) -> list"""
+ """replace numbers from start to end dividable by 3,5,15"""
result = []
for num in range(start, end):
element = ''
if num % 3 == 0:
element += 'such'
if num % 5 == 0:
element += 'much'
if element == '':
element += str(num)
result.append(element)
return result
-def count_doge_words( sentence ):
+def count_doge_words(sentence):
"""count parasite words from sentence"""
words = ('wow', 'lol', 'so', 'such', 'much', 'very')
counter = 0
- for word in sentence.split(' '):
+ for word in sentence.split():
if word in words:
counter += 1
return counter