How to display the same messages 5,4,8 or more times? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to display the same messages 5,4,8 or more times?

print("Welcome to Python") print("Welcome to Python") print("Welcome to Python") print("Welcome to Python") print("Welcome to Python")  As a beginner i code it like this.Is there any other method to code same messages more times? Or message="welcome to python" print(message*5) Can we modify this code to display message in difficult lines?

3rd May 2020, 5:49 PM
sumaiya sharmin
sumaiya sharmin - avatar
7 Answers
5th May 2020, 2:27 AM
narayanaprasad
narayanaprasad - avatar
+ 1
You can use for- or while-loops. Loops are covered in the python course, have a look at it :-)
3rd May 2020, 6:03 PM
Lisa
Lisa - avatar
+ 1
i=0; num_print=5; your_text="Your text here!"; while i < num_print: print(your_text); i+=1
3rd May 2020, 6:09 PM
Vlad Jonson
Vlad Jonson - avatar
+ 1
message =" welcome to python" print((message + '\n') * 5) very similar to your description example.
3rd May 2020, 7:04 PM
rodwynnejones
rodwynnejones - avatar
+ 1
For different lines you can go for the following code: print("Welcome to python \n" *5)
3rd May 2020, 7:34 PM
ANJALI SAHU
+ 1
Oh thanks 😊
3rd May 2020, 7:45 PM
sumaiya sharmin
sumaiya sharmin - avatar
0
a = 'do the python course' for I in range (5): print (a) Lisa said it best. Just do the python course, you'd understand more and better about this things.
3rd May 2020, 6:29 PM
Tomiwa Joseph
Tomiwa Joseph - avatar