Is there a way, lib, or something in python that I can set value in list at an index that does not exist? Something like runtime index creation at list:
l =
You cannot create a list with gaps. You could use a dict or this quick little guy:
dict
def set_list(i,v): l = [] x = 0 while x < i: l.append(None) x += 1 l.append(v) return l print set_list(3, 'foo') >>> [None, None, None, 'foo']