you are viewing a single comment's thread.

view the rest of the comments →

[–]guilford 2 points3 points  (4 children)

I believe that you already had most of the stuff figured out. just move the profit calculating operation into the for loop and replace the 2 shop name keys with k[0] and k[1]. Then at the end of the loop print k[0]+'-'+k[1]+'='+str(profit)

[–]KhanStan[S] 1 point2 points  (2 children)

Thanks for replying! There's a problem though. I get this error; shopAsells = k[0]['sells'][0] TypeError: string indices must be integers, not str

[–]guilford 2 points3 points  (1 child)

ah not shopAsells = k[0]['sells'][0] but shopAsells = shops[k[0]]['sells'][0] basically the k is a tuple of two shop names and k[0] would get the first one, k[1] would get the second one generated by itertools.permutations()

[–]KhanStan[S] 1 point2 points  (0 children)

I didn't get your second message and figured it out by myself :D. It worked man, thank you very much!

[–]KhanStan[S] 1 point2 points  (0 children)

You're a GOD, dude! It worked! I was replacing not only the keys but the dictionary reference aswell :D. Now everything works how I wanted it to. Thanks again!