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!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar
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
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar
+ 22
Thanks very much PÃŁŁÃVÎ JHÁ and Abhay
22nd Oct 2020, 12:45 PM
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar
+ 20
Abhay no number 3 its decide people with input y = input() print(y*"Sololearn") It give error
22nd Oct 2020, 12:43 PM
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar
+ 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
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar
24th Oct 2020, 4:14 AM
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar
+ 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
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar
23rd Oct 2020, 7:53 AM
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar
+ 13
Himanshu 😂😂
23rd Oct 2020, 12:57 PM
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar
+ 13
Welcome bro
23rd Oct 2020, 1:00 PM
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar
23rd Oct 2020, 4:41 PM
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar
+ 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
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar
23rd Oct 2020, 9:04 AM
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar
+ 11
Himanshu give link please
23rd Oct 2020, 12:52 PM
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar
23rd Oct 2020, 12:52 PM
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar