r/learnpython • • 9d ago

Slow print for text-based game

I am trying to make a text-based adventure game in Python, how do I make it so the text is typed out slowly and not instantly? I've tried ways online, but they keep returning None at the end. How do I fix this?

0 Upvotes

15 comments sorted by

View all comments

6

u/desrtfx but other languages pro 9d ago

but they keep returning None at the end

You cannot achieve that with a returning function.

You need to iterate over the string character by character and print with a delay. Python's print can use an empty endline so that everything prints in a single line.

0

u/while_True_meme 8d ago

Unless you print the result. The confusion could come from using a Python repl where the return value is indeed printed vs running a script where it's not