lang:python:condition
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| lang:python:condition [2020/02/20 00:14] – Ajout de "switch" root | lang:python:condition [2025/11/10 09:37] (Version actuelle) – [switch] : utilisation de match / case root | ||
|---|---|---|---|
| Ligne 19: | Ligne 19: | ||
| else: | else: | ||
| return 3 | return 3 | ||
| + | </ | ||
| + | |||
| + | ===Conditions multiples sur une même valeur=== | ||
| + | |||
| + | <code python> | ||
| + | if first in (' | ||
| + | print " | ||
| + | else: | ||
| + | print " | ||
| </ | </ | ||
| ====switch==== | ====switch==== | ||
| - | Le '' | + | <code python> |
| + | animal = " | ||
| + | match animal: | ||
| + | case " | ||
| + | print(" | ||
| + | case " | ||
| + | print(" | ||
| + | case "Python" | " | ||
| + | print(" | ||
| + | case _: | ||
| + | print(" | ||
| + | </code> | ||
lang/python/condition.1582154080.txt.gz · Dernière modification : de root
