top of page

Multi-line printing

You can use triple quotes to print strings on multiple lines in order to make text easier to read, or create a special text-based design.

 
 

My example code as follows

 

secret_number = 777 print( """ +================================+ | Welcome to my game, muggle! | | Enter an integer number | | and guess what number I've | | picked for you. | | So, what is the secret number? | +================================+ """) guessesTaken = 0 while guessesTaken != 777: print('Take a guess.') guess = input() guess = int(guess) guessesTaken = guessesTaken + 1 if guess < secret_number: print('Your guess is too low.') if guess > secret_number: print('Your guess is too high.') if guess == secret_number: break if guess == secret_number: guessesTaken = str(guessesTaken) print('Well done, muggle! You are free now. You guessed my number in ' + guessesTaken + ' guesses!') if guess != secret_number: secret_number = str(secret_number) print('Nope. The number I was thinking of was ' + secret_number)

 

Here is a similar programming as well as other resources about Python:

bottom of page