0

how to use the statement of repeat

repeat

3rd Jan 2021, 9:09 AM
Mr.Mouth
2 Answers
+ 5
By using a for loop: This code prints "Hello!" 5 times for i in range(5): print("Hello!") First you have to use a for loop that repeats 5 times by using range(5). So it prints "Hello!" 5 times. You can also see this code that includes other methods that a for loop can do: https://code.sololearn.com/camUZy7rjC1X/?ref=app
3rd Jan 2021, 9:10 AM
Baspberry
+ 2
do you mean in R? here is an example: v <- c("Hello","loop") cnt <- 2 repeat { print(v) cnt <- cnt+1 if(cnt > 5) { break } }
3rd Jan 2021, 9:29 AM
Martin Ed
Martin Ed - avatar