0
import numpy
import importlib

urls_1 =["a"]
urls_2 =["b"]
urls_3 =["c"]
urls_4 =["d"]
urls_5 =["e"]
urls_6 =["a"]
urls_7 =["b"]
urls_8 =["c"]
urls_9 =["d"]
urls_10 =["e"]

for i in range(1, 10):
    urls_1 = "a"
    urls_2 = "b"
    urls_3 = "c"
    urls_4 = "d"
    urls_5 = "e"
    n = 0+i
    urls_1 = ("urls_%s "%(n))
    print(urls_1)`

this is my code i want it to print a, b, c, d, e,

the value of urls_1 is urls_1 2 3 4 5 all the way to 10 but it's a string so here is the out put

urls_1 
urls_2 
urls_3 
urls_4 
urls_5 
urls_6 
urls_7 
urls_8 
urls_9 

the output that i want

a
b
c
d
e
a
b
c
d
e

i tried importlib but didn't work maybe i did it wrong

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • 1
    Use a dict. For example, `urls = {}`, then `urls[1] = ["a"]` etc. – 9769953 Jun 22 '23 at 06:08
  • Your title is rather incomprehensible: it's a runaway sentence. Please try and shorten it to be more comprehensible. – 9769953 Jun 22 '23 at 06:09
  • The output you want doesn't make much sense, compared to the part where you do `urls_1 = ("urls_%s "%(n))` and then print `urls_1`. That wouldn't print a single letter, so why would you do that? – 9769953 Jun 22 '23 at 06:11

0 Answers0