3 ms·
The second Python method that uses intermediary variable is what I use because it works much better with a debugger I also like this trick to avoid nested for
by UltraSane 2y ago
The second Python method that uses intermediary variable is what I use because it works much better with a debugger
I also like this trick to avoid nested for loops:
import itertools
names = ['Bob', 'Sam']
nums = [1,2]
letters = ['A','B']
for name,num,letter in itertools.product(names,nums,letters):
print(f"{name} {num} {letter}")
Bob 1 A
Bob 1 B
Bob 2 A
Bob 2 B
Sam 1 A
Sam 1 B
Sam 2 A
Sam 2 B