用户在 python 2.7 中回答 raw_input 所花费的计时时间

Timing time it takes for user to answer a raw_input in python 2.7

我在这里看到这段代码

import time

start = time.time()
in_str = raw_input("Enter the thing:")
end = time.time()
elapsed = end-start
print "That took you " + str(elapsed) + " seconds. Man, you're slow."

我想要这样,如果 elapsed < 10,它会打印 Man, you're fast instead of slow。我试过

if elapsed > 10 then print "" and if str(elspsed) > str(10): then do this but none of them see to work

import time

start = time.time()
in_str = raw_input("Enter the thing:")
end = time.time()
elapsed = end - start

if elapsed > 10:
    print "That took you " + str(elapsed) + " seconds. Man, you're slow."
else:
    print "You are fast! " + str(elapsed)