I don't know how slickest is, but I like this:
assert (['?'] * 3).join(',') == '?,?,?'
The operation * n in the list returns a list equal to this list connected n times, therefore ['?'] * 3 is equal to ['?', '?', '?'] . Then .join(',') simply .join(',') elements of this list.
source share