1

I'm trying to use the input function but every time, without fail, the word "None" appears at the end of my question/string (well running), it's capitalized just like that but has no overall effect on the code, it just ruins the project I'm working on.

Here's my code:

import time
import sys
def dp(s):
    for c in s:
        if c != " ":
            sys.stdout.write(c)
            sys.stdout.flush()
            time.sleep(0.22)
        elif c == " ":
            sys.stdout.write(c)
            sys.stdout.flush()
            time.sleep(0)

name = input(dp("Hello, whats your name? "))
1

1 Answer 1

2

Every function in python will return something, and if that something isn't defined it will be None (you can also explicitly return None in a function). So, your dp() function returns None, and so you are effectively calling input(None), which gives the same prompt of None.

Instead, try putting in input() call within the function itself.

def dp(s):
    for c in s:
        if c != " ":
            sys.stdout.write(c)
            sys.stdout.flush()
            time.sleep(0.22)
        elif c == " ":
            sys.stdout.write(c)
            sys.stdout.flush()
            time.sleep(0)
    return input()

name = dp("Hello, whats your name? ")
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.