Home > OS >  How can I make the for work in this function?
How can I make the for work in this function?

Time:10-12

could you help me with this problem? damned for! :p

def exchange(x):
    r = requests.get(URL1   x   URL2)
    js = r.json()
    df = pd.DataFrame.from_dict(js, orient="index").transpose()
    return df

if capture data with next code, after individual append() i have expected answer:

c = exchange("tiendacrypto")
d = exchange("belo")
c.append(d)

but, i don't find the error in the for:

a = []
for i in exchanges:
    print(exchange(i))
    a = exchange(i)
    a.append(a)

CodePudding user response:

The issue here is the reassignment of the a value on line 2 in the for loop.

You need to use a different variable name.

           
  • Related