user2970954
user2970954

Reputation: 89

Having trouble with time.sleep (python)

This is what I have done to import time

import pygame, random, time
from time import sleep

When it comes to the point in my code:

time.sleep(4)

I Get the error: AttributeError: 'module' object has no attribute 'sleep'

any ideas guys?

Upvotes: 1

Views: 1753

Answers (1)

trevorKirkby
trevorKirkby

Reputation: 1897

That is because you imported sleep directly from time. This means you can just call:

sleep(4)

instead of

time.sleep(4)

Another good solution would be to omit the code importing sleep specifically, so you get:

import pygame, random, time
#the "from time import sleep" line is deleted

time.sleep(4)

Upvotes: 2

Related Questions