how to overcome this.. hard quiz | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how to overcome this.. hard quiz

I was taking my python introduction lessons smoothly, then suddenly I came by this quiz that I must solve to complete the sequence... but the quiz's content is nothing I came passing by in the previous lessons... Anyway here is it any suggestions for a solution? {Write a program to take x and y as input and output the string x, repeated y times.} tried thia solution but it didn't work.. x = input("String") y = int(input("integer")) print(x'*y)

4th Oct 2023, 9:34 AM
4hmed0001
4hmed0001 - avatar
4 Answers
+ 10
Your code is correct... In third line...remove that apostrophe mark(') after x Here look at this... https://code.sololearn.com/c7MhQxM6e61o/?ref=app
4th Oct 2023, 9:44 AM
Riya
Riya - avatar
0
Mabey it will work ... x= input() y=int(input()) for i in range(y): print(x) If your y is int it will work
4th Oct 2023, 5:48 PM
Fateme Biglari
Fateme Biglari - avatar
0
Y should be an integer, as in a number like 1, 2, 3 etc and not the word 'integer'. So basically in Python when you multiply a string e.g "Python" by an integer e.g 2, it would repeat the string two times: "PythonPython". So your y should be a number and remove the single quote inside the print statement.
5th Oct 2023, 3:54 PM
Chuks AJ
Chuks AJ - avatar
0
4hmed0001 , When doing any Sololearn Code Coach or Practice, never include a prompt argument in your call of the input() function. The prompt gets printed and becomes part of the output of your program as far as the scoring engine is concerned, which won't match its expected output for each test case. I don't know how it is that new Python students get the idea to include a prompt with input() anyway, since Sololearn never teaches that technique.
23rd Jan 2024, 1:22 PM
Rain
Rain - avatar