So I want to create variables by looping through some sort of name assigning statement or function. I want to end up having variables titled “t1, t2, t3” etc. How can I accomplish what
i = 1
while 1:
("t" + str(i)) = [0,0,0,0]
i = i + 1
looks like it would do. (Keep the str("t") at the front than make the second character the changing int(i). This is to create variables to later put in an array without having to type them out in the the code.) I’m trying to make a list of 10,000 lists with 4 elements each. Is this more clear?
While it is technically possible to do what you want, it’s a really bad practice. This is exactly the use case that lists (or arrays) were made for, and you should be using one here.
Based on your code sample, something like
(as David Alber mentioned in a comment) should work for you; it will create a list of 10000 lists of 4 elements each.
P.S. In Python 3, the
xrangefunction has been renamed torange.