How to print 100 times a word | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to print 100 times a word

24th Jun 2023, 5:05 AM
Vishal Tiwari
Vishal Tiwari - avatar
16 Answers
+ 9
Use for loop
24th Jun 2023, 7:52 AM
Sakshi
Sakshi - avatar
+ 9
Vishal Tiwari , since python can multiply a string with an integer number, we can also use the print function with the string (to print) + a newline sequence, multiplied by the requested number.
24th Jun 2023, 2:01 PM
Lothar
Lothar - avatar
+ 6
Vishal Tiwari A quick and easy way is to use the repeat function from the itertools from itertools import repeat # defining number of times to repeat n = int(input()) # define the word or words to be printed w = input() or "Word" print(list(repeat(w, n)))
24th Jun 2023, 2:34 PM
BroFar
BroFar - avatar
+ 4
Learn programming
24th Jun 2023, 6:26 AM
A͢J
A͢J - avatar
+ 4
Python : for i in range(100): print("hello") Java : public class HelloWorld { public static void main(String[] args) { for (int i = 0; i < 100; i++) { System.out.println("hello"); } } } C: #include <stdio.h> int main() { for (int i = 0; i < 100; i++) { printf("hello\n"); } return 0; } C++ : #include <iostream> int main() { for (int i = 0; i < 100; i++) { std::cout << "hello" << std::endl; } return 0; } Kotlin : fun main() { repeat(100) { println("hello") } } JavaScript : for (let i = 0; i < 100; i++) { console.log("hello"); } Ruby : 100.times do puts "hello" end These are some examples of print "hello" 100 times, .there are some ways are present to print it
26th Jun 2023, 5:09 AM
Vaibhav
Vaibhav - avatar
+ 4
In python for i in range(100): print("hello")
26th Jun 2023, 8:31 AM
😇🌟SWATI🌟😇
😇🌟SWATI🌟😇 - avatar
+ 3
Welcome to SoloLearn Printing 100 times a word is one of the first things you will learn in any basic programming course. Hint: loops Keep learning and you'll get there. If you need help with a specific programming language you should make that clear in the question tags.
24th Jun 2023, 5:38 AM
Kevin ★
+ 2
Use for loop by giving range
24th Jun 2023, 12:02 PM
Vanshita Tripathi
+ 1
Vishal Tiwari You could just say print(“Hello” * 100) and that would print it 100 times and if you want to print it all on new lines you can use the new line character print(“Hello\n” * 100)
24th Jun 2023, 5:55 PM
Junior
Junior - avatar
+ 1
In python just to write For i in range(100): Print(word) Word will printed 100 times
25th Jun 2023, 1:53 PM
shreeraksha Gourayya
shreeraksha Gourayya - avatar
+ 1
For many languages I'll propose use of a loop because it's short and easy.
25th Jun 2023, 10:34 PM
Leeroy Mokua
Leeroy Mokua - avatar
0
Use for loop for i in range(100): print("Your message")
25th Jun 2023, 3:47 PM
Mohd Arman
Mohd Arman - avatar
0
#include <iostream> int main() { std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word\n"; std::cout<<"word";}
25th Jun 2023, 8:52 PM
Fukari Floryda
Fukari Floryda - avatar
0
Fukari Floryda What if i wanted to print world\n 10k times?
25th Jun 2023, 11:42 PM
Junior
Junior - avatar
0
You can use loop to do that, while or for loop
26th Jun 2023, 12:22 AM
Waris Kehinde
Waris Kehinde - avatar