Hi...

Let's say that we have this:

somme = raw_input('1 + 1 = ')
if somme == 2:
	print 'Good  - Time For Answer: '
else:
	print 'False  - The Right Answer is: 2   -Time For Answer:'

So... how can we get the time for writing any things on raw_input()

Recommended Answers

You can use time.time()

import time
before = time.time()
somme = raw_input('1 + 1 = ')
diff = time.time() - before # time difference in seconds as a floating point number
Jump to Post

All 3 Replies

You can use time.time()

import time
before = time.time()
somme = raw_input('1 + 1 = ')
diff = time.time() - before # time difference in seconds as a floating point number

It's work... but can't we use another way :d

try this

import time
before = time.time()
print("Started time stamp"),time.ctime(before)
somme = raw_input('1 + 1 = ')
if somme.strip() == '2':
   diff = time.time() # time difference in seconds as a floating point number
   print("ended time: "),time.ctime(diff)
   print("Time diff in seconds :"),diff-before
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.