Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Bigger Price by mjazy
def bigger_price(limit, data):
array = []
cutArray = [None] * limit
index = 0
counter = 0
returnList = []
print(returnList)
for dictionary in data:
array.append(dictionary['price'])
print(counter)
counter += 1
array = sorted(array)
while index < limit:
print('hello')
cutArray[index] = array[len(array)-1-index]
index += 1
print(index)
print(cutArray, 'cutArray')
index = 0
while index < limit:
print(returnList)
for dictionary in data:
print(returnList, 'returnList')
print(cutArray, 'cutArray')
if index != limit:
if dictionary['price'] == cutArray[index] and dictionary['price'] not in returnList:
returnList.append(dictionary)
index += 1
print('been in there')
print(returnList)
# your code here
return returnList
if __name__ == '__main__':
from pprint import pprint
print('Example:')
pprint(bigger_price(2, [
{"name": "bread", "price": 100},
{"name": "wine", "price": 138},
{"name": "meat", "price": 15},
{"name": "water", "price": 1}
]))
# These "asserts" using for self-checking and not for auto-testing
assert bigger_price(2, [
{"name": "bread", "price": 100},
{"name": "wine", "price": 138},
{"name": "meat", "price": 15},
{"name": "water", "price": 1}
]) == [
{"name": "wine", "price": 138},
{"name": "bread", "price": 100}
], "First"
assert bigger_price(1, [
{"name": "pen", "price": 5},
{"name": "whiteboard", "price": 170}
]) == [{"name": "whiteboard", "price": 170}], "Second"
print('Done! Looks like it is fine. Go and check it')
Jan. 22, 2018