Skip to content
Related Articles

Related Articles

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






# 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 

 

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :