Making pairs of two people
Predict the output · Medium · §7.6 Nested loops and the first math helper
To check whether four people follow each other, the code makes every pair of two people. Predict the output without running the code.
Code
members = ["dami", "taeo", "yuna", "siwoo"]
count = 0
for i in range(len(members)):
for j in range(i + 1, len(members)):
print(members[i], members[j])
count += 1
print(count)Solve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.