rename a variable using format in python

Solutions on MaxInterview for rename a variable using format in python by the best coders in the world

showing results for - "rename a variable using format in python"
Timeo
22 Jan 2017
1arraysList = []
2for i in range(0,3):
3    arraysList.append([1,2,3])
4
5print arraysList
6# [[1, 2, 3], [1, 2, 3], [1, 2, 3]]
7print arraysList[1]
8# [1, 2, 3]
Leon
21 Feb 2019
1arraysDict = {}
2for i in range(0,3):
3    arraysDict['x{0}'.format(i)] = [1,2,3]
4
5print arraysDict
6# {'x2': [1, 2, 3], 'x0': [1, 2, 3], 'x1': [1, 2, 3]}
7print arraysDict['x1']
8# [1,2,3]