# File: stringTest1.py # # Using + to construct a string is slow if the new character # is added to the front of the string. It's much better to # add a character at the end. # import time import random REPS = 800000 # REPS = 10 random.seed() aString = "" start = time.time() for i in range (0, REPS): newLetter= chr(random.randint(32,126)) aString = newLetter + aString # aString = aString + newLetter # print(aString) finish = time.time() print("Elapsed time =", finish - start, "seconds")