0

How do I make something have a small delay in python?

I want to display something 3 seconds after afterwards and then let the user input something.

Here is what I have

print "Think of a number between 1 and 100"
print "Then I shall guess the number"

I want a delay here

print "I guess", computerguess
raw_input ("Is it lower or higher?")
Siddharth Satpathy
  • 2,737
  • 4
  • 29
  • 52
bradymat
  • 37
  • 1
  • 4
  • 1
    No? I'm new, but thanks for the link – bradymat May 09 '13 at 23:48
  • 1
    It definitely is an exact duplicate. My comment was auto-posted when I voted to close as a duplicate, it wasn't a question. It just means your question has already been answered. – Gareth Latty May 09 '13 at 23:49
  • 5
    Hi bradymat, welcome to SO. Don't be disheartened if this question is closed as a duplicate - we try to keep a single authoritative question/answer for each problem. It's nothing personal, just that it's a common question. If you'd googled your question title, the first result is the question this has been marked as a duplicate of. – Basic May 09 '13 at 23:50
  • 1
    I understand it is a similar topic – bradymat May 09 '13 at 23:51
  • 2
    @bradymat A duplicate on SO doesn't mean that the question is exactly the same, rather that the answer to one question answers yours. There is no need to have multiple questions that all have the same answer, so we consolidate them like this. Your question is answered perfectly by the linked question. In future, before you ask a question, it's best to search for an answer using google or the search function - it's faster than posting a duplicate like this, and easier for everyone. – Gareth Latty May 09 '13 at 23:58

3 Answers3

4

This should work.

import time
print "Think of a number between 1 and 100"
print "Then I shall guess the number"

time.sleep(3)

print "I guess", computerguess
raw_input ("Is it lower or higher?")
Caedan Lavender
  • 344
  • 1
  • 3
  • 12
  • 1
    Thanks Mr Lavender this is exactly what I needed, I shall accept this answer when I am able to do so in 7 minutes time, this answer is phenomenally worded, the spacing is what sets it apart from the others – bradymat May 09 '13 at 23:56
2

Try this:

import time

print "Think of a number between 1 and 100"
print "Then I shall guess the number"

time.sleep(3)

print "I guess", computerguess
raw_input ("Is it lower or higher?")

The number 3 indicates the number of seconds to pause. Read here.

Justin O Barber
  • 11,291
  • 2
  • 40
  • 45
  • 1
    Thank you Mr user1775603 but the lack of spacing makes it harder for me to decipher exactly what is going on between the lines of code I have provided in the question. – bradymat May 09 '13 at 23:59
  • 2
    You have very delicate eyes Mr bradymat – wim May 10 '13 at 02:00
2
    import time

    print "Think of a number between 1 and 100"
    print "Then I shall guess the number"

    time.sleep(3) 

    print "I guess", computerguess
    raw_input ("Is it lower or higher?")
Kevin Bowersox
  • 93,289
  • 19
  • 159
  • 189