Last active
February 20, 2025 12:43
-
-
Save TGITS/7a6040d1de4b64f391aebf9776034d3b to your computer and use it in GitHub Desktop.
Exemple boucle avec while et sans break équivalente à celles avec le for et un break.
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: ") | |
not_found = True | |
i = 0 | |
while i < len(noble_gaz) and not_found: | |
if noble_gaz[i]["symbol"] == symbol: | |
print( | |
f"Vous avez entré le symbole de {noble_gaz[i]['name']} dont le numéro atomique est {noble_gaz[i]['atomic number']}" | |
) | |
not_found = False | |
break | |
i += 1 | |
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