Home > Back-end >  Python typewriter function returning none when used within input?
Python typewriter function returning none when used within input?

Time:06-27

    import random,sys,time,os 
os.system("cls")
def dialogue(passage):              # Function for dialogue to type slowly
     for letter in passage:
         sys.stdout.write(letter)
         sys.stdout.flush()
         time.sleep(0.1) 
name = input(dialogue("Hi, WHat is your name?")) 

the input would pop up in the terminal as "Hi, WHat is your name?"NONE. is there any way I can change this to just return the input without it stating NONE where the output should be?

CodePudding user response:

Just add return '' to the end of the dialogue function:

def dialogue(passage):
    for letter in passage:
         sys.stdout.write(letter)
         sys.stdout.flush()
         time.sleep(0.1) 
    return ''
         
name = input(dialogue("Hi, What is your name? ")) 
  • Related