def assign_keywords(resource):
 for i in range(0, randint(0, 5)):
  resource.keywords.add(('keyword_%s' % randint(0, n_keywords)))

def assign_keywords ( resource ) : for i in range ( 0 , randint ( 0 , 5 ) ) : resource . keywords . add ( ( 'keyword_%s' % randint ( 0 , n_keywords ) ) )
assigns up to 5 keywords to resource .