'$'.join(list(str))
import itertools as it
ss = 'python'
# The way digda posted it
'$'.join(it.repeat(ss, 5))
'python$python$python$python$python'
# You can just do * 5.
'{}$'.format(ss) * 5
'python$python$python$python$python$'
# Remove last character $
('{}$'.format(ss) * 5)[0:-1]
'python$python$python$python$python'
*Extra length
Try it in GO language
https://play.golang.org/p/m8hOxlE3Mkb
package main
import (
"fmt"
"strings"
)
func main() {
ss := "python"
s1 := strings.Repeat(ss+"$", 5) // strings.Repeat(fmt.Sprintf("%s$", ss), 5)
fmt.Println(s1[0 : len(s1)-1]) // python$python$python$python$python
L := []string{}
for i := 0; i < 5; i++ {
L = append(L, ss)
}
s2 := strings.Join(L[:], "$")
fmt.Println(s2) // python$python$python$python$python
}
© 2025 OneMinuteCode. All rights reserved.