I would like to replace this nested loop with itertools.product
:
seasons = ['long', 'short']
weathers = ['dry', 'wet', 'sunny']
for season in seasons:
for weather in weathers:
output = "S= " + season + "&" + "W= " + weather
print(output)
Output
S= long&W= dry
S= long&W= wet
S= long&W= sunny
S= short&W= dry
S= short&W= wet
S= short&W= sunny
I know I can print all elements using this:
mylist = list([seasons, weathers])
for element in itertools.product(*mylist):
print(element)
But how can I call individual elements within itertools.product
?