import random #this function generates the string #using random numbers and conversion #to character #function returns randomly generated string def randomString(size): #this function generates the string #using random numbers and conversion #to character #function returns randomly generated string my_string="" for i in range(size): num=random.randint(33, 126) letter=chr(num) my_string=my_string+letter #could be written #my_string=my_string+chr(random.randint(33,126)) return my_string