-5

I have this code(example):

count = 3

def test(count):
    a = 1
    while a <= count:
        global list + str(a)
        list + str(a) = []
        print(a)
        a += 1

test(count)

print(list1)
print(list2)
print(list3)

How can I create dynamically global variable(list) in function? I need to make my code working, need access to variables(lists): "list1", "list2" and "list3" from function outside.

Thanks

Morgan Thrapp
  • 9,748
  • 3
  • 46
  • 67
Petro Pikh
  • 118
  • 1
  • 2
  • 9

1 Answers1

0

Many thanks for all. I used this code:

count = 3
urls = {}

def test(count):
    a = 1
    while a <= count:
        urls[a] = 'test'
        a += 1

test(count)
print(urls)
Petro Pikh
  • 118
  • 1
  • 2
  • 9