Défi
Énoncé
Lire deux entiers a et b sur deux lignes de l'entrée standard. Échanger leurs valeurs en une seule affectation Python — a, b = b, a — sans déclarer de variable temporaire. Afficher a puis b après l'échange, chacun sur sa propre ligne.
Contraintes
- Python ≥ 3.0.
- L'échange doit se faire avec l'unpacking tuple en une seule ligne (
a, b = b, a). - Interdiction d'utiliser une variable temporaire
tmp. - Les deux entiers sont signés et tiennent dans un
intPython standard. - Bibliothèque standard uniquement.
Exemple
7
3
3
7
Après a, b = b, a, a vaut 3 et b vaut 7.