import string import random def rubegoldberg(): alpha = string.ascii_lowercase find, total = "codewars", 1 for x, y in enumerate(find): if x % 2 == 0: total += alpha.index(y) else: total -= alpha.index(y) total -= len(find) nums = [] for i in range(0, 10): nums.append(i) random.shuffle(nums) try: for n in nums: a = 1 / n except ZeroDivisionError: return total
- import string
- import random
- def rubegoldberg():
- alpha = string.ascii_lowercase
- find, total = "codewars", 1
- for x, y in enumerate(find):
- if x % 2 == 0:
- total += alpha.index(y)
- else:
- total -= alpha.index(y)
- total -= len(find)
return total- nums = []
- for i in range(0, 10):
- nums.append(i)
- random.shuffle(nums)
- try:
- for n in nums:
- a = 1 / n
- except ZeroDivisionError:
- return total
Add something to the function's logic so that it still returns 1!
def rubegoldberg():
return 1
test.assert_equals(rubegoldberg(), 1)