Pretty new to python, and can't work out (or find) how to check an array based on a variable name.
Eg:
type = "world"
world_arr = []
town_arr = []
#add to an array
[type + '_arr'].append('test') <-- how?
Pretty new to python, and can't work out (or find) how to check an array based on a variable name.
Eg:
type = "world"
world_arr = []
town_arr = []
#add to an array
[type + '_arr'].append('test') <-- how?
Do not look up variable names dynamically. It's a major code smell. Use a dict.
lists = {
'world': [],
'town': []
}
type = 'world'
lists[type].append('test')