Python Unordered List Mess up

For three weeks one tiny bug was bugging me supremely.

In Artemis, I made the mistake of choosing BankNIFTY PCR whereas it is uniformly NIFTY PCR. But, I was unable to hunt up what was the mistake. The end results is quite intriguing.

for symbol in {‘NIFTY’,‘BANKNIFTY’}:

What I was thinking it will print NIFTY first and BANKNIFTY next but it was not the case. It is unordered and random. And, hence, Mother of all problems.

Anyways, the proper turnaround is -

symbol_list = ['NIFTY','BANKNIFTY']
for z in range(0,len(symbol_list)):

Just noting down one of my nightmares. Just, plucking my hair on this issue made me refactor the entire thing twice from the ground up.

1 Like