Dec-17-2020, 03:44 PM
Here's some code:
The result of the last line is "Black"
If I leave the asterisk out, the result of the last line is "['Black', 'White']
What happened to White when I tried to unpack the list?
Thanks!
1 2 3 4 5 6 |
print () print ( 'This program will print out a set containing all colors from color_list_1 {"White", "Black", "Red"} that are not present in color_list_2 {"Red", "Green"}.' ) color_list_1 = set ([ "White" , "Black" , "Red" ]) color_list_2 = set ([ "Red" , "Green" ]) print () print ( 'Colors meeting stated criteria are {}.' . format ( * [i for i in color_list_1 if i not in color_list_2])) |
If I leave the asterisk out, the result of the last line is "['Black', 'White']
What happened to White when I tried to unpack the list?
Thanks!