I have this array which is working:
urls = [
'a.com/%s' % page for page in xrange(1,4,1)
]
However, when I tried this, it's not.
urls = [
'a.com/%s' % page for page in xrange(1,4,1),
'b.com/%s' % page for page in xrange(1,4,1)
]
The error message is NameError: name 'page' is not defined
How can I generate an array like this in shorthand?
urls = [
'a.com/1',
'a.com/2',
'a.com/3',
'b.com/1',
'b.com/2',
'b.com/3',
]
Update:
Some has suggested that this post is duplicated with this post: How to append list to second list (concatenate lists), however, I disagree.
Even though the solution is the same, however, the purpose of the question is different. Just in case, there are other users wonder how to use multiple xrange in array, then the answer to this question, or the other question could be their best answer.