Last active
February 20, 2025 12:43
-
-
Save TGITS/7e3e008caea93d481a57962f2aa3793e to your computer and use it in GitHub Desktop.
Exemple d'une boucle for avec une clause else
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
noble_gaz = [ | |
{"name": "HELIUM", "symbol": "He", "atomic number": 2}, | |
{"name": "NEON", "symbol": "Ne", "atomic number": 10}, | |
{"name": "ARGON", "symbol": "Ar", "atomic number": 18}, | |
{"name": "KRYPTON", "symbol": "Kr", "atomic number": 36}, | |
{"name": "XENON", "symbol": "Xe", "atomic number": 54}, | |
{"name": "RADON", "symbol": "Rn", "atomic number": 86}, | |
] | |
symbol = input("Entrer le symbole d'un gaz noble: ") | |
for gaz in noble_gaz: | |
if gaz["symbol"] == symbol: | |
print( | |
f"Vous avez entré le symbole de {gaz['name']} dont le numéro atomique est {gaz['atomic number']}" | |
) | |
break | |
else: | |
print( | |
f"Le symbole {symbol} que vous avez saisi ne semble pas correspondre à un gaz rare" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment