Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-mini-2024-07-18· OpenAIAi2 WildChat-4.8M (AI2)

give me a while true loop that prints HelloWorld every one millisecond..

  1. User

    give me a while true loop that prints HelloWorld every one millisecond..

  2. Assistant

    To create a while true loop that prints "HelloWorld" every millisecond in Python, you can use the time module to add a delay. Here's an example:

    import time
    
    while True:
        print("HelloWorld")
        time.sleep(0.001)  # Sleep for 1 millisecond
    

    This script will run indefinitely, printing "HelloWorld" every millisecond. To stop it, you would typically use a keyboard interrupt (like Ctrl + C). Please note that running such a tight loop can overload your terminal or consume excessive CPU resources, depending on your system's performance.