Reputation: 13
By printing out of raw_input() appears at the end a "none".
I defined above a function to look nice when printing the question.
Here's my code:
def delay_print_input(string):
for c in string:
sys.stdout.write(c)
sys.stdout.flush()
time.sleep(0.15)
ans=raw_input(delay_print_input("What do you want?\n>> "))
The output looks like:
What do you want?
>> None
My question is, how can I remove this none?
Upvotes: 0
Views: 74
Reputation: 714
Your function is returning None and sending it to the input function. You can just return a blank string in your function
def delay_print_input(string):
for c in string:
sys.stdout.write(c)
sys.stdout.flush()
time.sleep(0.15)
return ""
Upvotes: 1
Reputation: 27333
Your function returns None, which raw_input
then prints. What you want is this:
def delay_print_input(string):
for c in string:
sys.stdout.write(c)
sys.stdout.flush()
time.sleep(0.15)
delay_print_input("What do you want?\n>> ")
ans=raw_input()
Upvotes: 3