1

So I definitely know that saying this:

x = input(print('hello what is ur name uwu:')

Would produce:

hello what is ur name uwu:None

But here is my code:

import sys
import time
from colorama import Fore

def crawl(text,ti):
  for char in text:
    sys.stdout.write(char)
    sys.stdout.flush()
    time.sleep(ti)

input(crawl(Fore.RED + 'Well, hello there my dear player!',0.1))

and as expected... it produces:

Well, hello there my dear player!None

I tried doing this:

crawl(input(Fore.RED + 'Well, hello there my dear player!'),0.1)

and it produces correctly but there is one problem... it produces it instantaneously and my crawl function should drag it out letter by letter. Please help.

1 Answers1

1

built-in input function will print arguments if they are given.

The prompt string, if given, is printed to standard output without a trailing newline before reading input.

So you shouldn't give arguments to input.
You can simply separate calling crawl and input.

Note: I removed colorama dependency since it is not relevant with your question.

import sys
import time


def crawl(text, ti):
    for char in text:
        sys.stdout.write(char)
        sys.stdout.flush()
        time.sleep(ti)


crawl('Well, hello there my dear player!', 0.1)
x = input()
print(x)

output:

Well, hello there my dear player!5
5

5 was my std input.

Boseong Choi
  • 2,566
  • 9
  • 22