salut,
j'ai une question sur python.
pourquoi on ajoute 6 à text_width, et pourquoi on ajoute -2 à box_width ?
et merci d'avance.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 sentence = input("Sentence: ") screen_width = 80 text_width = len(sentence) box_width = text_width + 6 left_margin = (screen_width - box_width) // 2 print (' ' * left_margin + '+' + '-' * (box_width-2) + '+') print (' ' * left_margin + '| ' + ' ' * text_width + ' |') print (' ' * left_margin + '| ' + sentence + ' |') print (' ' * left_margin + '| ' + ' ' * text_width + ' |') print (' ' * left_margin + '+' + '-' * (box_width-2) + '+')
Partager