help me ?

Peter Otten __peter__ at web.de
Mon Feb 26 05:45:49 EST 2018


Christian Gollwitzer wrote:

> Am 26.02.18 um 10:40 schrieb sotaro237 at gmail.com:
>> Define 2 lists. The first one must contain the integer values 1, 2 and 3
>> and the second one the string values a, b and c. Iterate through both
>> lists to create another list that contains all the combinations of the A
>> and B elements. The final list should look like one of the 2 lists: 1.
>> [1a, 1b, 1c, 2a, 2b, 2c, 3a, 3b, 3c
> 
> Look up list comprehensions.

Hm, this will teach the OP a concise way to rewrite the solution once he has 
solved the problem with the conventional nested for loops, list.append(), 
and str.format()...




More information about the Python-list mailing list