instead of using two for loops in python

+1 vote
for pro in product:
    for ser in service:
        if (
            pro['attributes']['code']
            == ser['relationships']['service']['data']['id']
        ):
            service_attributes.append(ser['attributes']['service-parameters'])
        else:
            service_attributes.append(None)
Dec 22, 2019 in Python by anonymous
• 130 points
938 views

1 answer to this question.

+1 vote

This example might help:

for x, y in ((a,b) for a in [1,2,3] for b in [5,6,7]):
  print x, y
answered Dec 24, 2019 by Sumeir

Related Questions In Python

+1 vote
1 answer
0 votes
1 answer

How can I compare the content of two files in Python?

Assuming that your file unique.txt just contains ...READ MORE

answered Apr 16, 2018 in Python by charlie_brown
• 7,720 points
2,365 views
0 votes
1 answer

How do you get the logical xor of two variables in Python?

If you're already normalizing the inputs to ...READ MORE

answered May 29, 2018 in Python by aryya
• 7,450 points
10,462 views
0 votes
1 answer

When to use %r instead of %s in Python? [duplicate]

The %s specifier converts the object using ...READ MORE

answered Aug 2, 2018 in Python by bug_seeker
• 15,520 points
852 views
0 votes
1 answer

How do you get the logical xor of two variables in Python?

What i found is that you can use ...READ MORE

answered Aug 10, 2018 in Python by Priyaj
• 58,090 points
11,328 views
0 votes
1 answer

Avoiding multiple nested for-loops in python

You can replace the three loops with: from ...READ MORE

answered Sep 7, 2018 in Python by Priyaj
• 58,090 points
615 views
0 votes
1 answer

Avoiding multiple nested for-loops in python

You can replace the three loops with: from ...READ MORE

answered Sep 10, 2018 in Python by Priyaj
• 58,090 points
2,967 views
0 votes
2 answers

Avoiding multiple nested for-loops in python

Instead of multi-loop, If you can categorize ...READ MORE

answered Sep 15, 2018 in Python by pedro67657
• 160 points

edited Sep 15, 2018 by Vardhan 15,649 views
0 votes
4 answers

How to print objects of class using print function in Python?

>>> class Test: ... ...READ MORE

answered Dec 16, 2020 in Python by Roshni
• 10,520 points
77,550 views
0 votes
1 answer

How to check latest change time of each file using glob in python?

You can get the changing time from ...READ MORE

answered Jan 2, 2019 in Python by Omkar
• 69,210 points
1,161 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP