Files
training.python.beginner/training/code/02-language-basics/08-sets/sets_03.py
2025-07-04 19:26:39 +02:00

22 lines
590 B
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Al et Kim sont inscrits sur un réseau social. Al a les amis suivants :
#
# - Josephine
# - Meghan
# - Amy
# - Bob
#
# Kim a les amis suivants :
#
# - Frank
# - Amy
# - Josephine
# - Susan
#
# Quels sont leurs amis en commun ? Écrivez un code qui représente et résout cet énoncé.
al_friends = {"Josephine", "Meghan", "Amy", "Bob"}
kim_friends = {"Frank", "Amy", "Josephine", "Susan"}
# Afficher le bon résultat
print(al_friends & kim_friends) # Affichier l'intersection avec des opérateurs
print(al_friends.intersection(kim_friends)) # Affichier l'intersection plus explicite