Hey there, I am having the issue on Codewars where I pass all the basic tests but somehow I am failing the random tests. Here our two separate problems where I feel like I’ve written good working code but its not letting my attempt pass.
Problem 1:
Thinkful - Dictionary drills: Order filler
You’re running an online business and a big part of your day is fulfilling orders. As your volume picks up that’s been taking more of your time, and unfortunately lately you’ve been running into situations where you take an order but can’t fulfill it.
You’ve decided to write a function fillable()
that takes three arguments: a dictionary stock
representing all the merchandise you have in stock, a string merch
representing the thing your customer wants to buy, and an integer n
representing the number of units of merch they would like to buy. Your function should return True
if you have the merchandise in stock to complete the sale, otherwise it should return False
.
Valid data will always be passed in and n
will always be >= 1.
MY CODE:
def fillable(stock, merch, n):
if merch in stock:
quantity = stock[merch]
if n > quantity:
return False
elif n < quantity:
return True
else:
return False
Problem 2:
Return the first M multiples of N
Implement a function, multiples(m, n)
, which returns an array of the first m
multiples of the real number n
. Assume that m
is a positive integer.
Ex.
multiples(3, 5.0)
should return
[5.0, 10.0, 15.0]
MY CODE:
def multiples(m, n):
list = []
num = 0
n = int(n)
for i in range(m):
num = n * (i+1)
num = float(num)
list.append(num)
return list
Error message for problem 1 is "none should equal True"
Error message for problem 2 is " [3.0] should equal [3.14]"
Any help figuring this out is greatly appreciated.
Thanks