Get repetition of strings in Julia – ^ operator
Last Updated :
23 Feb, 2021
The ^ is an operator in julia which is used to repeat the specified string with the specified number of times.
Syntax:
^(s::Union{AbstractString, AbstractChar}, n::Integer)
Parameters:
- s::Union{AbstractString, AbstractChar}: Specified strings or characters
- n::Integer: Specified integer
Returns: It returns a new repeated string.
Example 1:
Python
println( "GFG " ^ 3 )
println( "GeekforGeeks " ^ 2 )
println( "abc " ^ 2 )
println( "a " ^ 4 )
|
Output:
GFG GFG GFG
GeekforGeeks GeekforGeeks
abc abc
a a a a
Example 2:
Python
println( "1-" ^ 3 )
println( "123 " ^ 2 )
println( "5& " ^ 2 )
println( "0 * 0 " ^ 4 )
|
Output:
1-1-1-
123 123
5& 5&
0*0 0*0 0*0 0*0
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...