> exercise. I need to rewrite the high_low.py program (see below) to use the > last two digits of time at that moment to be the "random number". This is > using the import time module. > > I just can't work out how to do that, I have been looking at it for the past > 2,5 hours but can't break it. Has anyone done it in order for me to study > it. >
There are several ways, one is to convert the time number into a string and then extract the last two digits and convert back to a number. n = time.time() s = str(n) ran = s[-2:] # last two characters of the string ran = int(ran) # convert back to a number Another option is to divide by 100 and take the remainder... HTH, Alan G. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor