Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

import time
import random

print "Wanna play a game?"

raw_input(),
time.sleep(1)
print ("Think of a number (1-5), I won't see, I promise. 
"),
    time.sleep(5)

print "You picked? Now write it down."
raw_input(),
time.sleep(3)

print ("Let me guess... 
"),
    time.sleep(2)

print ((random.randint(1, 5))), 
    time.sleep(20000)

When I run it in terminal, this happens:

Wanna play a game?

yes
Think of a number (1-5), I won't see, I promise. 
None
You picked? Now write it down.
Let me guess... 
None
1

Why does "none" pop up?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
140 views
Welcome To Ask or Share your Answers For Others

1 Answer

The , in your code adding a new argument to the print statements and printing it, which in this case is the return value of time.sleep() (None)

Remove those, fix the indentation, and it works.

import time
import random

print "Wanna play a game?"

raw_input()
time.sleep(1)
print ("Think of a number (1-5), I won't see, I promise. 
")
time.sleep(5)

print "You picked? Now write it down."
raw_input()
time.sleep(3)

print ("Let me guess... 
")
time.sleep(2)

print ((random.randint(1, 5)))
time.sleep(20000)

Output:

Wanna play a game?
y
Think of a number (1-5), I won't see, I promise. 
You picked? Now write it down.
1
Let me guess... 
3

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...