Skip to content
Sign upLog in
← Back to Community

Center a code.

Profile icon
Elizabeth_Mason

Hello, I am trying to get my code in the center, and I can't figure it out. Can someone send me the code so I can center it?

Answered by Vandesm14 [earned 5 cycles]
View Answer
Voters
Profile icon
StarlynaJurado
Profile icon
ChristopherEll9
Profile icon
Elizabeth_Mason
Comments
hotnewtop
Profile icon
Vandesm14

If you mean CSS:

text-align: center
Profile icon
Elizabeth_Mason

@Vandesm14
Sorry I did specify, I wan to get it centered in python.

Profile icon
Vandesm14

@Elizabeth_Mason Then you need to calculate the length of the string, and the width of the terminal (in characters).
Then just subtract the terminal width by the string length set that to your padding value. Then take your padding value and insert padding/2 spaces before the string. Finally, print to console.

Profile icon
JosiahCerda

!DOCTYPE html>

repl.it

JOSIAH CERDA

DAILY SCHEDULE

ODD

EVEN

Block 1-2

English

spanish

Block 3-4

bible

web dev

Block 5-6

physics

geometry

Block 7-8

SS

Draw 1

My Aug Prep Activities

basketball

Invalid image url

  • Basketball Practice
  • streangth and conditioning
  • going to classes
  • College Program/internships

  • (UWM College Program)
  • Faith and Service

  • I help at my granpas church, and i help others with basketball practice.
  • <script src="script.js"></script>