1

I want to store strings in different variables. Below is the code which provides a powerset of strings from given symbols.

import pandas as pd
import numpy as np
from itertools import combinations, chain

def powerset(iterable):                                                                                                                                                                                                    
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))

symbols = ['KEL','BYCO']
combinations = list(powerset(symbols))
del combinations[0]
my_list = combinations

my_list contains a list of strings as follows.

[('KEL',), ('BYCO',), ('KEL', 'BYCO')]

I want the element on 0th position to be likesymbol_0 = ('KEL'). To make sufficent amount of variables to incorporate the whole list I've used the following code.

for i in range(0,list_len):
    symbol_i = 0
    pass
print(symbol_0)

I expected the above code to make 3 variables namely symbol_0, symbol_1 and symbol_2. I don't get why when I print symbol_0, I get an error symbol_0 is not defined.

Furqan Hashim
  • 1,304
  • 2
  • 15
  • 35

0 Answers0