In Python it is easy to create a string of n characters:
>>> '=' * 40
'========================================'
However, in Julia the above does not work. What is the Julia equivalent to the Python code above?
In Python it is easy to create a string of n characters:
>>> '=' * 40
'========================================'
However, in Julia the above does not work. What is the Julia equivalent to the Python code above?
In Julia you can replicate a single character into a string of n characters, or replicate a single-character string into a string of n characters using the ^ operator. Thus, either a single-quoted character, '=', or a double-quoted single character, "=", string will work.
julia> '='^40 # Note the single-quoted character '='
"========================================"
julia> "="^40 # Note the double-quoted string "="
"========================================"
Another way to do do the same thing is:
julia> repeat('=', 40)
"========================================"
julia> repeat("=", 40)
"========================================"