You are using the same name time for both the time module and the argument of your function. However, if you want to do this you don't need to define a new function yourself. Python supports reassigning functions to different variable names, so you could just do wait = time.sleep (note its important we didn't include any parentheses at the end, so we are not calling the function but rather referring to the function itself.) This yields the same results as your code; you can use wait(1) instead of time.sleep(1). Also, you can import the function directly instead of importing the whole module, ie. from time import sleep Then you can just use sleep(1) in your code without having to refer to the time module. If you still wanted to use the name wait, you can give it another name when importing the function, ie. from time import sleep as wait. Answer from AtomicShoelace on reddit.com
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-time-sleep
Python time.sleep(): How to Pause Execution in Python Scripts | DigitalOcean
January 27, 2026 - This function is part of Python’s standard time module and is widely used in scripts that require controlled delays. In this article, you will learn how the time.sleep() function works and how to use it correctly in different scenarios. It explains how to add delays measured in seconds, how time.sleep() affects program execution, and why it pauses only the current thread rather than the entire application.
🌐
GeeksforGeeks
geeksforgeeks.org › python › sleep-in-python
time.sleep() in Python - GeeksforGeeks
July 11, 2025 - Python time sleep() function suspends execution for the given number of seconds.
Discussions

How to use time.sleep() within a function correctly?
You are using the same name time for both the time module and the argument of your function. However, if you want to do this you don't need to define a new function yourself. Python supports reassigning functions to different variable names, so you could just do wait = time.sleep (note its important we didn't include any parentheses at the end, so we are not calling the function but rather referring to the function itself.) This yields the same results as your code; you can use wait(1) instead of time.sleep(1). Also, you can import the function directly instead of importing the whole module, ie. from time import sleep Then you can just use sleep(1) in your code without having to refer to the time module. If you still wanted to use the name wait, you can give it another name when importing the function, ie. from time import sleep as wait. More on reddit.com
🌐 r/learnpython
8
4
February 9, 2021
time.sleep() - odd timing results

Correct usage of perf_counter:

from time import perf_counter, sleep

s=perf_counter()
sleep(3)
e=perf_counter()
print(e-s)
More on reddit.com
🌐 r/learnpython
7
2
June 27, 2016
[Question] A more accurate time.sleep() ?
https://stackoverflow.com/a/26609843/10254804 https://stackoverflow.com/a/28034554/10254804 More on reddit.com
🌐 r/learnpython
4
8
October 9, 2018
time.sleep() not working?
You need to import the time module. Put at the top of your script: import time More on reddit.com
🌐 r/learnpython
4
9
December 17, 2017
🌐
Hostman
hostman.com › tutorials › python time.sleep() function: a comprehensive guide
Python time.sleep() Function: How to Use and Best Practices
December 11, 2024 - What is the sleep() Function in Python? Python's time.sleep() function can be used to freeze the current thread's execution for a specific period of time. The built-in time module in Python contains this function.
Price   $
Address   1999 Harrison St 1800 9079, 94612, Oakland
🌐
Python
docs.python.org › 3 › library › time.html
time — Time access and conversions
Similar to process_time() but return time as nanoseconds. Added in version 3.7. ... Suspend execution of the calling thread for the given number of seconds. The argument may be a floating-point number to indicate a more precise sleep time.
🌐
StrataScratch
stratascratch.com › blog › python-sleep-function
How to Use Python’s Sleep Function - StrataScratch
October 14, 2025 - What it does is stop your program from running for a certain amount of time. You could think of it as a short-term "wait" order. The program does nothing else while it sleeps; it just stays still. If you’d like to explore more advanced techniques for introducing execution delays, check out ...
🌐
Tutorialspoint
tutorialspoint.com › python › time_sleep.htm
Python time sleep() Method
Once compiled and run, the program prints the numbers after sleeping for 2 seconds each − · Start program 0 Program halted for 2 seconds 1 Program halted for 2 seconds 2 Program halted for 2 seconds 3 Program halted for 2 seconds 4 Program ...
Find elsewhere
🌐
Programiz
programiz.com › python-programming › time › sleep
Python sleep() (With Examples)
import time print("Printed immediately.") time.sleep(2.4) print("Printed after 2.4 seconds.") ... Printed immediately. Printed after 2.4 seconds. ... import time while True: # get current local time as structured data current_time = time.localtime() # format the time in 12-hour clock with AM/PM formatted_time = time.strftime("%I:%M:%S %p", current_time) print(formatted_time) time.sleep(1)
🌐
Zero To Mastery
zerotomastery.io › blog › python-sleep
Beginner’s Guide to Python’s Sleep Command | Zero To Mastery
Using tools like Python, GPTs, and more! ... It'll show you how to automate all of the boring or repetitive tasks in your life - and makes for some pretty standout portfolio projects as well! With all that out of the way, let's get into this 5-minute tutorial! At its heart, time.sleep() is Python’s way of pausing whatever it’s doing at the time.
🌐
Reddit
reddit.com › r/learnpython › how to use time.sleep() within a function correctly?
r/learnpython on Reddit: How to use time.sleep() within a function correctly?
February 9, 2021 -

Long story short i am making a rpg games (text based) in python and need a little help. I am using the time library to give a delay between certain ASCII banners popping up in the console. However, i dont want to have to write out 'time.sleep()' or copy and paste it every time i want to use it. Therefore, i made a function which I would use to shorten the time it would take me to right out 'time.sleep()':

def wait(time):

time.sleep(time)

wait(1)

Whilst in theory i thought this would work (im new to python, i have much to learn yet), it gives me this error:

time.sleep(time)

AttributeError: 'int' object has no attribute 'sleep'

I was wondering if anyone could help/point me in the right direction on how to go about this problem. Thanks in advance!

🌐
Mimo
mimo.org › glossary › python › time-sleep
Python time sleep: Pausing Code Execution in Python
Pause Python programs with time.sleep(). Learn to add delays for tasks, manage countdowns, limit API requests, and create smooth workflows.
🌐
Analytics Vidhya
analyticsvidhya.com › home › mastering the python time.sleep() function
Mastering the Python time.sleep() Function
January 19, 2024 - The time.sleep() function, a built-in Python feature, enables you to halt code execution for a specified duration.
🌐
Tencent Cloud
tencentcloud.com › pt › document › product › 248 › 65496
Connecting Python Applications Using OpenTelemetry- ...
October 13, 2025 - Tencent Cloud is a secure, reliable and high-performance cloud compute service provided by Tencent. Tencent is now the largest Internet company in China, even in Asia, which provides services for millions of people via its flagship products like QQ and WeChat.
🌐
iO Flood
ioflood.com › blog › python-wait
Python Sleep Methods | How to Make Code Pause or Wait
August 21, 2024 - This function makes Python wait for a specified number of seconds. ... import time time.sleep(5) # Makes Python wait for 5 seconds # Output: # (After a 5 second delay, the program continues...)
🌐
WsCube Tech
wscubetech.com › resources › python › sleep
sleep() in Python: Syntax, Parameters, Examples
October 1, 2025 - Learn about Python's sleep() function, its syntax, parameters, and examples to pause code execution for a specified time in this step-by-step tutorial.
🌐
AskPython
askpython.com › home › using the python time.sleep() method
Using the Python time.sleep() Method - AskPython
August 6, 2022 - The Python time.sleep() method is used to halt the execution of the current program/thread for a given amount of time.
🌐
Instagram
instagram.com › popular › time-sleep-function-python
Time Sleep Function Python
2 weeks ago - We cannot provide a description for this page right now
🌐
Edureka
edureka.co › blog › python-time-sleep
Python time Sleep() | time.Sleep() Method in Python | Edureka
November 27, 2024 - If you want to stop execution for a smaller period of time there are limitations to this function depending on the operating system as this function uses operating systems sleep() function, in Linux the wait time can be smaller than that compared with windows. ... In the above article we covered the sleep() method in python which is basically used to add a delay in program execution, this package is in the time module in Python which basically uses sleep() function of the underlying operating system.
🌐
IONOS
ionos.com › digital guide › websites › web development › python sleep
How does the Python sleep function work? - IONOS
February 1, 2023 - Simply request the current time and output it in the format hour, minutes, seconds. Then set a delay of exactly one second and command the program to loop again using Python sleep.
🌐
Sentry
sentry.io › sentry answers › python › time delay in python
Time delay in Python | Sentry
March 15, 2023 - We can do this using the sleep() function in Python’s built-in time module. This function will pause execution by a provided number of seconds.
🌐
Real Python
realpython.com › python-sleep
Python sleep(): How to Add Time Delays to Your Code – Real Python
August 1, 2023 - The time module has a function sleep() that you can use to suspend execution of the calling thread for however many seconds you specify. ... If you run this code in your console, then you should experience a delay before you can enter a new ...