Get repetition of a string in Julia – repeat() Method
Last Updated :
26 Mar, 2020
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:
println(repeat( "gfg" , 3 ))
println(repeat( "a" , 4 ))
println(repeat( "Geeks" , 2 ))
println(repeat( "@#" , 3 ))
|
Output:
gfggfggfg
aaaa
GeeksGeeks
@#@#@#
Example 2:
println(repeat( "123" , 3 ))
println(repeat( "22" , 4 ))
println(repeat( "03210" , 2 ))
|
Output:
123123123
22222222
0321003210
Share your thoughts in the comments
Please Login to comment...