Решение на doge от Даяна Маринова

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

Към профила на Даяна Маринова

Резултати

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

Код

def wow_such_much(start, end):
result = []
for number in range(start, end):
if number % 15 == 0:
result.append('suchmuch')
elif number % 3 == 0:
result.append('such')
elif number % 5 == 0:
result.append('much')
else:
result.append(str(number))
return result
def count_doge_words(string):
string = string.lower()
list_of_words = ['wow', 'lol', 'so', 'such', 'much', 'very']
list_of_string = string.split(" ")
count = 0
for item in list_of_string:
for items in list_of_words:
if item == items:
count += 1
return count

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

...............
----------------------------------------------------------------------
Ran 15 tests in 0.007s

OK

История (5 версии и 1 коментар)

Даяна обнови решението на 06.03.2014 01:27 (преди над 10 години)

+def wow_such_much(start, end):
+ result = []
+ for number in range(start,end):
+ if number % 15 == 0:
+ result.append('suchmuch')
+ elif number % 3 == 0:
+ result.append('such')
+ elif number % 5 == 0:
+ result.append('much')
+ else:
+ result.append(str(number))
+ return result
+
+print (wow_such_much(1, 16))
+print (wow_such_much(30, 46))

Даяна обнови решението на 06.03.2014 01:37 (преди над 10 години)

def wow_such_much(start, end):
result = []
for number in range(start,end):
if number % 15 == 0:
result.append('suchmuch')
elif number % 3 == 0:
result.append('such')
elif number % 5 == 0:
result.append('much')
else:
result.append(str(number))
return result
print (wow_such_much(1, 16))
-print (wow_such_much(30, 46))
+print (wow_such_much(30, 46))
+
+
+def count_doge_words(string):
+ list_of_words = ['wow', 'lol', 'so', 'such', 'much', 'very']
+ list_of_string = string.split(" ")
+ count = 0
+ for item in list_of_string:
+ for items in list_of_words:
+ if item == items:
+ count += 1
+ return count
+
+print (count_doge_words("wow much hard such difficult"))

Принтовете са излишни. Също така, когато call-ваш print, не слагай интервал преди (, както и при другите function calls. На 3-ти ред аргументите start и end трябва да са разделени с интервал: range(start, end). Хубаво е да прекарваш кода през PEP8 checker.

Даяна обнови решението на 06.03.2014 12:12 (преди над 10 години)

def wow_such_much(start, end):
result = []
- for number in range(start,end):
+ for number in range(start, end):
if number % 15 == 0:
result.append('suchmuch')
elif number % 3 == 0:
result.append('such')
elif number % 5 == 0:
result.append('much')
else:
result.append(str(number))
return result
-print (wow_such_much(1, 16))
-print (wow_such_much(30, 46))
-
def count_doge_words(string):
list_of_words = ['wow', 'lol', 'so', 'such', 'much', 'very']
list_of_string = string.split(" ")
count = 0
for item in list_of_string:
for items in list_of_words:
if item == items:
count += 1
return count
-
-print (count_doge_words("wow much hard such difficult"))

Даяна обнови решението на 07.03.2014 16:13 (преди над 10 години)

def wow_such_much(start, end):
result = []
for number in range(start, end):
if number % 15 == 0:
result.append('suchmuch')
elif number % 3 == 0:
result.append('such')
elif number % 5 == 0:
result.append('much')
else:
result.append(str(number))
return result
def count_doge_words(string):
+ string.lower()
list_of_words = ['wow', 'lol', 'so', 'such', 'much', 'very']
list_of_string = string.split(" ")
count = 0
for item in list_of_string:
for items in list_of_words:
if item == items:
count += 1
return count

Даяна обнови решението на 07.03.2014 16:37 (преди над 10 години)

def wow_such_much(start, end):
result = []
for number in range(start, end):
if number % 15 == 0:
result.append('suchmuch')
elif number % 3 == 0:
result.append('such')
elif number % 5 == 0:
result.append('much')
else:
result.append(str(number))
return result
def count_doge_words(string):
- string.lower()
+ string = string.lower()
list_of_words = ['wow', 'lol', 'so', 'such', 'much', 'very']
list_of_string = string.split(" ")
count = 0
for item in list_of_string:
for items in list_of_words:
if item == items:
count += 1
return count