0
how to use the statement of repeat
repeat
2 ответов
+ 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
+ 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
}
}