-1

There is an error in this code...

time.sleep(5)
print ("Loading Successfull")`

When I run this code an error pops up it says:

NameError: name 'time' is not defined

I think I dont need to define time

I've recently have used this command it never said TimeError it's happening first time

print ("-----------------Welcome to Digits counter-----------------")#Welcomes the user
print ("")
print ("Loading...")
time.sleep (3)
print("Load Sucessfull")
ash
  • 5,139
  • 2
  • 27
  • 39
S_z
  • 9
  • 5
  • 1
    Import the module `import time` – Rakesh May 11 '18 at 17:23
  • 1
    Like this? `import time` `time.sleep (3)` – S_z May 11 '18 at 17:25
  • 1
    Now, simply "import time" – Simeon Ikudabo May 11 '18 at 17:26
  • 1
    Cant wait to see the full "Digits counter" app up and running ;) Maybe you would want to reconsider a "loading" phase which does nothing except for sleeping. – Merlin1896 May 11 '18 at 17:27
  • @Merlin1896 for some reason young/new programmers love the idea of loading screens. It makes their app feel more special or like it's doing more or something. I think it's a phase we grow out of. :D – DavidScherer May 11 '18 at 17:32
  • 1
    @DavidScherer True. I bet I would find similar lines in my old code. – Merlin1896 May 11 '18 at 17:33
  • 1
    @Merlin1896 I certainly could. There was time I spent more time making cool and unnecessary loaders than I did writing actual code. Now days we spend more time getting rid of loading and user wait times than we do writing actual code. – DavidScherer May 11 '18 at 17:37
  • 2
    Possible duplicate of [Python 3.3.3 time.sleep() error](https://stackoverflow.com/questions/23616507/python-3-3-3-time-sleep-error) – ash May 11 '18 at 17:53

1 Answers1

3

you need to import time module first.

import time

time.sleep(5)

Or instead of importing full time module, just import sleep from time:

from time import sleep
sleep(5)

rest of the code, remains same.

akshat
  • 1,219
  • 1
  • 8
  • 24