+ 106

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

22nd Oct 2020, 12:31 PM
Sofi♥️
72 Answers
+ 62
Sist Try : First enter number second enter any word val_a = int(input()) val_b = str(input()) sofi = (val_a*val_b) print(sofi)
22nd Oct 2020, 12:47 PM
Prachi The Pari ⭐
Prachi The Pari ⭐ - avatar
+ 25
Thank you very much Prachi The Pari 🎸 Sist❤
22nd Oct 2020, 12:51 PM
Sofi♥️
+ 22
Thanks very much PÃŁŁÃVÎ JHÁ and Abhay
22nd Oct 2020, 12:45 PM
Sofi♥️
+ 20
Abhay no number 3 its decide people with input y = input() print(y*"Sololearn") It give error
22nd Oct 2020, 12:43 PM
Sofi♥️
+ 17
But where should the word repeat? In console or in the string itself, or something else...
22nd Oct 2020, 12:34 PM
777
777 - avatar
+ 17
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!
22nd Oct 2020, 12:37 PM
Sofi♥️
24th Oct 2020, 4:14 AM
Sofi♥️
+ 14
Sofi💕 input() returns a string ,you need to cast the result to int to be able to multiply strings print(int(y)*"Sololearn!")
22nd Oct 2020, 12:44 PM
Abhay
Abhay - avatar
23rd Oct 2020, 5:39 AM
Sofi♥️
23rd Oct 2020, 7:53 AM
Sofi♥️
+ 13
Himanshu 😂😂
23rd Oct 2020, 12:57 PM
Sofi♥️
+ 13
Welcome bro
23rd Oct 2020, 1:00 PM
Sofi♥️
23rd Oct 2020, 4:41 PM
Sofi♥️
+ 12
3*"Sololearn!" Sofi💕
22nd Oct 2020, 12:39 PM
Abhay
Abhay - avatar
+ 12
print(int(input()) * input())
24th Oct 2020, 6:02 PM
David Ashton
David Ashton - avatar
+ 11
Can give you an example? Like what are the inputs and output you expect?
22nd Oct 2020, 12:33 PM
Abhay
Abhay - avatar
+ 11
VAIBHAV KUMAR you write in c++ but thank you
23rd Oct 2020, 7:23 AM
Sofi♥️
23rd Oct 2020, 9:04 AM
Sofi♥️
+ 11
Himanshu give link please
23rd Oct 2020, 12:52 PM
Sofi♥️
23rd Oct 2020, 12:52 PM
Sofi♥️