Open In App

Get repetition of a string in Julia - repeat() Method

Last Updated : 12 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report
The repeat() is an inbuilt function in julia which is used to return a string which is the repetition of specified string with specified number of times.
Syntax: repeat(String::AbstractString, r::Integer) Parameters:
  • String: Specified string or character
  • r::Integer: Specified number of times
Returns: It returns a string which is the repetition of specified string with specified number of times.
Example 1: Python
# Julia program to illustrate 
# the use of String repeat() method

# Create a repetition of string "gfg"
# with 3 times of repetition.
println(repeat("gfg", 3))

# Create a repetition of character "a"
# with 4 times of repetition.
println(repeat("a", 4))

# Create a repetition of string "Geeks"
# with 2 times of repetition.
println(repeat("Geeks", 2))

# Create a repetition of string "@#"
# with 3 times of repetition.
println(repeat("@#", 3))
Output:
gfggfggfg
aaaa
GeeksGeeks
@#@#@#
Example 2: Python
# Julia program to illustrate 
# the use of String repeat() method
 
# Create a repetition of string "123"
# with 3 times of repetition.
println(repeat("123", 3))
 
# Create a repetition of string "22"
# with 4 times of repetition.
println(repeat("22", 4))
 
# Create a repetition of string "03210"
# with 2 times of repetition
println(repeat("03210", 2))
Output:
123123123
22222222
0321003210

Article Tags :

Similar Reads