15,851,514 members
See more:
hello
i really dont know how even should i ask this it was hard for me and tried multiple ways but couldnt figure it out.

i have 2 dicts lets say:
`buy = { 99 : 10, 100 : 9, 102 : 12, 103 : 15}`

`sell = {101 : 12 , 100.5 : 13, 99 : 14, 98 : 18}`

keys are prices and values are quantities so i want to buy cheap and sell expensive.
but quantity have a limitation here .
i know what i should looking for its something like this in step by step.
step1:
```buy = {100 : 9, 102 : 12, 103 : 15}
sell = {101 : 2 , 100.5 : 13, 99 : 14, 98 : 18}```

step2:
```buy = {100 : 7, 102 : 12, 103 : 15}
sell = {100.5 : 13, 99 : 14, 98 : 18}```

step3:
```buy = {102 : 12, 103 : 15}
sell = {100.5 : 6, 99 : 14, 98 : 18}```

here there isnt any thing for me to buy cheap and sell expensive

can guide me what should i do
thanks a lot

What I have tried:

```buy_p  = []
sell_p  = []
sell_q = []```

```for i in range(len(buy_p)):
else:

this one was the closest one but it not obeying the steps
Posted
Updated 2-Aug-22 1:39am
Richard MacCutchan 2-Aug-22 6:48am
You forgot to explain the rules for the steps, and it is not clear exactly what you are trying to do.
OriginalGriff 2-Aug-22 6:59am
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
Imagine this: you go for a drive in the country, but you have a problem with the car. You call the garage, say "it broke" and turn off your phone. How long will you be waiting before the garage arrives with the right bits and tools to fix the car given they don't know what make or model it is, who you are, what happened when it all went wrong, or even where you are?

That's what you've done here. So stop typing as little as possible and try explaining things to people who have no way to access your project!

I'd start by going back to your assignment, and reading it carefully - we can't see it so we have no idea what rules you are supposed to be following.

Use the "Improve question" widget to edit your question and provide better information.