How to turn this code to a f string?

  • A+
colors = ['black', 'white'] sizes = ['S', 'M', 'L'] for tshirt in ('%s %s' % (c, s) for c in colors for s in sizes):     print(tshirt)  black S black M black L white S white M white L 

So I am trying to remove those %s %s and instead have a f string formatting. Can someone be kind enough to show how this is done. Thanks


>>> colors = ['black', 'white'] >>> sizes = ['S', 'M', 'L'] >>> for c in colors: ...    for s in sizes: ...        print(f'{c} {s}') 

Another approach is to use itertools.product:

>>> for c, s in itertools.product(colors, sizes): ...     print(f'{c} {s}')    


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: