jeudi 10 janvier 2019

Loop inside a loop with an if statement

I have the following loop.

for i in range(0, len(stockscsidata.Exchange.values)):    
    if stockscsidata.Exchange.values[i] == "TSX":
        stockscsidata.Symbol.values[i] = stockscsidata.Symbol.values[i] + ".TO"

What I would like to do is

1- Instead of "Toronto" use a this list

exchange_list = ("TSX", "VSE")

2- The If statement would be if exchange_list == TSX then add + ".TO" or if exchange_list == VSE then add +".V"

How could I do this and what would the code look like?

Thx!

Aucun commentaire:

Enregistrer un commentaire