+ 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
Սոֆի
73 Respuestas
+ 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
Սոֆի
+ 22
Thanks very much PÃŁŁÃVÎ JHÁ and Abhay
22nd Oct 2020, 12:45 PM
Սոֆի
+ 20
Abhay no number 3 its decide people with input y = input() print(y*"Sololearn") It give error
22nd Oct 2020, 12:43 PM
Սոֆի
+ 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
Սոֆի
24th Oct 2020, 4:14 AM
Սոֆի
+ 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
Սոֆի
23rd Oct 2020, 7:53 AM
Սոֆի
+ 13
Himanshu 😂😂
23rd Oct 2020, 12:57 PM
Սոֆի
+ 13
Welcome bro
23rd Oct 2020, 1:00 PM
Սոֆի
23rd Oct 2020, 4:41 PM
Սոֆի
+ 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
Սոֆի
23rd Oct 2020, 9:04 AM
Սոֆի
+ 11
Himanshu give link please
23rd Oct 2020, 12:52 PM
Սոֆի
23rd Oct 2020, 12:52 PM
Սոֆի