 How to do so that when you type the word, the word is repeated as many times as the number written by user??? | SoloLearn: Learn to code for FREE!

+37

# How to do so that when you type the word, the word is repeated as many times as the number written by user???

In python

+37

Sist Try : First enter number second enter any word val_a = int(input()) val_b = str(input()) sofi = (val_a*val_b) print(sofi)

+18

n=int(input()) x=input() for i in range (0,n): print(x) i=i+1 there so many others method using loops 😊

+14

Thank you very much Prachi The Pari 🎸 Sist❤

+13

But where should the word repeat? In console or in the string itself, or something else...

+13

Thanks very much PÃŁŁÃVÎ JHÁ and Abhay

+12

Abhay no number 3 its decide people with input y = input() print(y*"Sololearn") It give error

+11

Abhay @vrintle Example: User write in input number 3 and output is Sololearn!Sololearn!Sololearn! Or user write number 6 and output is Sololearn!Sololearn!Sololearn!Sololearn!Sololearn!Sololearn!

+10

Sofi💕 input() returns a string ,you need to cast the result to int to be able to multiply strings print(int(y)*"Sololearn!")

+10

you can use loop y=input() while True: print(y+"Sololearn") This loop repeats number to infinite time in python.Don't forget to give space for print(y) afrer while True: as I gave above and donot write y*"Sololearn as it cannot multiply string, instead of multiplying (*) you can give add(+) as I gave above and run your program. For example if you give y value as Sofi, then it will print -Sofisololearn to infinite times until it reaches execution time out, this means it has reached its printing limit and cannot print more.

+8

3*"Sololearn!" Sofi💕

+8

Thanks BroFar, Hardik PandiT, Naam Mein Kya Rakha Hai 😈

+8

print(int(input()) * input())

+7

Can give you an example? Like what are the inputs and output you expect?

+7

Thanks Himanshu Atomic Wave ~⚛ Zeal Shah Mark Evans

+7

Himanshu and <<SGI>>[Exams📘] tnx

+7

Sofi sister please see my code.

+7