Issue
In python I'm trying to write nested loops in one line. I've seen a lot of examples, but in all of them the inner iterable variable is different compared to the outer one. So in my case, it won't work. Here's my try:
my_list = [for ip in subnet for subnet in subnets]
where I'm getting:
Unresolved reference 'subnet'
Solution
There is a syntax error, it should be
my_list = [ip for subnet in subnets for ip in subnet]
Answered By - cmauck10
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.