0

hi i want to ask if how i can put one line space in python 3. i use this code:

#def space():
#print()

but when i want to print it there is a "none" that prints for me but i want just a line with nothing i.e i want to type :

"hi how are you :

iam fine" 

i want to have the space between "hi how are you " and "iam fine" i give this to python3 :

print('hi how are you",space(),"iam fine")

but it will give me only:

 hi how are you None iam fine ..

what is the problem here? what dose this none means?

2 Answers 2

1

print() happens immediately. If you want a newline then you need to return '\n' instead.

Sign up to request clarification or add additional context in comments.

1 Comment

i see .. but i still have problem with it how do i have to return'\n' ?
0

this is what you want:

def space():
    return '\n'

None is what it sounds like, it's printing None because you're not giving print() any inputs

5 Comments

The None is the return value of the space function, it has nothing to do with the inputs to print.
this is what i get in python wen i use your code: >>> def space(): return '\n' >>> space() '\n'
@user1893221: Try the snippet you originally posted with the new function: print("hi how are you", space(), "I am fine")
i got it so now if i want more space like 3 lines between my strings i have to def angain by two return'\n' ? i tried it its not working ...
ps: please upvote/choose answers on stack overflow if you got an answer to your question!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.