Simplification ? [Résolu]

Signaler
-
Messages postés
13221
Date d'inscription
lundi 9 juin 2008
Statut
Contributeur
Dernière intervention
22 novembre 2020
-
Bonjour, je souhaiterais simplifier se code si possible : D

arrow = "[[darkyt]]~>"
    if curseur_choix == 1:
        line1 = arrow
        line2 = line3 = line4 = line5 = line6 = "  "
    if curseur_choix == 2:
        line2 = arrow
        line1 = line3 = line4 = line5 =  line6 = "  "
    if curseur_choix == 3:
        line3 = arrow
        line1 = line2 = line4 = line5 =  line6 = "  "
    if curseur_choix == 4:
        line4 = arrow
        line1 = line2 = line3 = line5 =  line6 = "  "
    if curseur_choix == 5:
        line5 = arrow
        line1 = line2 = line3 = line4 =  line6 = "  "
    if curseur_choix == 6:
        line6 = arrow
        line1 = line2 = line3 = line4 =  line5 = "  "

    print(colorText(menu_txt.format(line1, line2, line3, line4, line5, line6)))


Configuration: Windows / Chrome 86.0.4240.183

1 réponse

Messages postés
13221
Date d'inscription
lundi 9 juin 2008
Statut
Contributeur
Dernière intervention
22 novembre 2020
739
bonjour,
la première simplification serait d'utiliser un tableau plutôt que 6 variables pour line.