 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 | Sololearn: Learn to code for FREE!

+3

# 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 😑

+7

Hello :3 It is simply: print(input()*int(input()))

+6

Adi Nath Bhawani Your for loop is unnecessary. You can just multiply string by int: x*y = 'hi'*3 = 'hihihi' :)

+6

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)

+5

x = input() y = int(input()) print((x*y)[:y]) Use (x*y)[:y] for printing 'hih' else only (x*y)

+4

Shouldn't it be 'hihihi'? The code is fairly simple. You take an input twice. The second time convert it to int, then print the product so first input × second input.

+4

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

+3

x= input(" ") y= int (input()) Output=(x*y) Print(Output)

+3

print(input ()*3) It will automatically typecast in string because the default is string in input

+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"

+2

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

+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()))

+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

+1

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])

+1

Guys we don't need to print "hi" three time. This is just sample text, I don't know what to fill in input 😕

+1

Then try which I gave with respect to hih then see if it works or not. I hope it works 🤞

+1

+1

x = input() y =input() def mult_st(x, y): return x*int(y) mult_st()

+1

x=input() y=int(input()) Print(x*y)