Skip to content
Related Articles
Open in App
Not now

Related Articles

Get repetition of strings in Julia – ^ operator

Improve Article
Save Article
Like Article
  • Last Updated : 23 Feb, 2021
Improve Article
Save Article
Like Article

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




# Julia program to illustrate
# the use of operator ^
 
# Get repetition of different strings
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




# Julia program to illustrate
# the use of operator ^
 
# Get repetition of different strings
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 

 

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!