Skip to content

Instantly share code, notes, and snippets.

@TGITS
Last active February 20, 2025 12:43
Show Gist options
  • Save TGITS/6d241fcf169173dbf3bed2028e00f3c4 to your computer and use it in GitHub Desktop.
Save TGITS/6d241fcf169173dbf3bed2028e00f3c4 to your computer and use it in GitHub Desktop.
Exemple de script avec une boucle for sans clause else
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: ")
found = False
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']}"
)
found = True
break
if not found:
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