0

Write a program to take x and y as input and output the string x, repeated y times. Sample Input hi 3 Sample Output hih

Pls someone help me i am stuck at this question 😑

17th Jan 2022, 3:43 PM
Abdul Wahab
19 Answers
+ 8
Hello :3, Due to question you have 2 different input,bone should be string, named x, another is integer, named y. x = input() # input is already string as default y = int(input()) # now sure it is integer So the result is print(x * y) # will give you y times string x
18th Jan 2022, 10:59 AM
SoloilSole
SoloilSole - avatar
+ 5
x = input() y = int(input()) print((x*y)[:y]) Use (x*y)[:y] for printing 'hih' else only (x*y)
17th Jan 2022, 5:42 PM
Shubham jadhav
Shubham jadhav - avatar
+ 4
Hello :3 Python has functionality to print string multiple times so if you want to print hi 3 times then just do this: print ('hi' * 3) Since there are many test cases so you have to take input then implement like this: print (input() * 3)
17th Jan 2022, 4:34 PM
A͢J
A͢J - avatar
+ 3
x= input(" ") y= int (input()) Output=(x*y) Print(Output)
18th Jan 2022, 10:16 AM
SK SANOWAR
+ 3
print(input ()*3) It will automatically typecast in string because the default is string in input
18th Jan 2022, 5:38 PM
Hellock
+ 3
print(input()*int(input)) That will do the work perfectly The first input gets the string and the second inputs gets the number of times that the string is repeated
19th Jan 2022, 2:59 AM
Franco Basilone
+ 2
If it has to print "hih" only, then try this x=input() y=int(input()) z="" for i in range(1,y+1): z=z+x print(z[0:y])
17th Jan 2022, 4:00 PM
Adi Nath Bhawani
Adi Nath Bhawani - avatar
+ 2
Guys we don't need to print "hi" three time. This is just sample text, I don't know what to fill in input 😕
17th Jan 2022, 6:35 PM
Abdul Wahab
+ 2
# Run in Ruby editor def code(x,y) p (x * y)[0...y] # multipy string x, y times # [0...y] is a range to select the string chars from 0 upto y end code "hi",3 # "hih"
19th Jan 2022, 1:00 AM
Manish Johari
Manish Johari - avatar
+ 2
So the sample output would be hi 3 times: “hihihi” So to break it down, first you need to store the user inputs in the variables x and y: x = input() y = input() Since y is an int you need to convert it from the string input: y = int(y) If you want to store your output in a variable you can so: output = x * y Then print the output: print(output) Hopefuly breaking it down helps you see it better. You can write it more concisely like other answers like so: print(input()*int(input()))
19th Jan 2022, 6:36 AM
Kevin Griffith
+ 1
x=input() y=int(input()) z="" for i in range(1,y+1): z=z+x print(z) If it has to print hihihi
17th Jan 2022, 3:57 PM
Adi Nath Bhawani
Adi Nath Bhawani - avatar
+ 1
Then try which I gave with respect to hih then see if it works or not. I hope it works 🤞
17th Jan 2022, 6:35 PM
Adi Nath Bhawani
Adi Nath Bhawani - avatar
+ 1
RIP u got em.. THC
18th Jan 2022, 9:55 AM
Abdul Wahab
+ 1
x = input() y =input() def mult_st(x, y): return x*int(y) mult_st()
18th Jan 2022, 11:40 PM
Omar
Omar - avatar
+ 1
x=input() y=int(input()) Print(x*y)
19th Jan 2022, 6:25 AM
Yasvanth Hanumantu
Yasvanth Hanumantu - avatar
0
This is the Solution x=input('') y=int(input('')) print(x*y)
7th Sep 2022, 5:47 AM
Engr Amin
Engr Amin - avatar