1

The following code creates a list of strings

N = 6       # Number of bank accounts
Banks = ["" for x in range(N)]
for x in range(1,len(Banks)+1):
    Banks[x-1] = 'B' + str(x)

Creates: Banks = ['B1','B2','B4','B5','B6']

I would like to create variables named from these strings, without typing out B1 =, B2 =, etc., i.e. for it to be in a for loop (Or something similarly automated). This will also allow the automatic creation of additional variables if the value of N is increased.

B1 = .....
B2 = .....
B1BR = .....
B5BR = ......

The last two are further variables with BR at the end.

Thanks for any help. I am fairly new to python.

tedioustortoise
  • 259
  • 3
  • 20

0 Answers0