user2598164
user2598164

Reputation: 35

More elegant way to produce a space python

I don't know if this question can be answered. I am new to python. I have been using the command print to create a blank space in the output to the python idle shell.

I was wondering is there an easier or more elegant way of creating this white space in the output or is print the only way this can be done??

Upvotes: 0

Views: 62

Answers (1)

TerryA
TerryA

Reputation: 60014

Add a new line to the end:

print 'hello\n'
print 'hi'

Prints:

hello

hi

This can be very helpful for taking in inputs because you can't just stick a print in the middle of an input:

name = raw_input("What is your name?\n> ")
print "Hello {}!".format(name)

When run:

What is your name?
> Haidro
Hello Haidro!

Upvotes: 2

Related Questions