0

i was creating this program which checks whether 2 items on a list add up to a certain amount of credits i have however each item should be counted only once..

the first part was giving me the correct solution while the second one was executing some cases twice..

so what exactly would the difference between 'not e==j' and 'e is not j' be?

for j in range(len(prices)):
    for e in range(j,len(prices)):
        if(int(prices[j])+int(prices[e])==creds and (not e==j)):
            if(j<e):
                    something
            else:
                    something

for j in range(len(prices)):
    for e in range(j,len(prices)):
        if(int(prices[j])+int(prices[e])==creds and (e is not j)):
            if(j<e):
                    something
            else:
                    something
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
otaku
  • 849
  • 2
  • 13
  • 33

0 Answers0