How to join strings from a Cartesian product of two lists

前端 未结 4 463
野趣味
野趣味 2021-01-28 11:15

I have two lists of strings:

letters = [\'abc\', \'def\', \'ghi\']
numbers = [\'123\', \'456\']

I want to for loop through them to create a lis

4条回答
  •  萌比男神i
    2021-01-28 11:43

    Thank you for your answers! I simplified the case, so all of the above solutions work well, however in the real problem I'm working on I want to add more lines of code in between that would iterate through both lists. I completed it nesting those for loops:

    for letter in letters:
       for number in numbers:
          print(letter+number)
          # many many lines of more code
    

    Anyway, thanks a lot for your help!

提交回复
热议问题