0

Practice 15.2

I really feel that in the python beginners course there is a bug in practice 15.2. they try to make me a a solution that will form 'hihihi'. I've done this in several ways. Although at the result page it keeps saying that I need to make 'coolcool' or 'aaaaaaaa'. I'm completely lost in what I have to do and can't continue my learning although I feel like what I am doing is correct Edit: Write a program to take x and y as input and output the string x, repeated y times. Sample Input hi 3 Sample Output hihihi My answer (among numerous) x=input("hi") y=int(3) print(x*y)

10th Feb 2022, 6:28 PM
Bart Mertens
6 Answers
+ 1
Pls post your try along with the task description clearly... that helps to find if any mistake. edit: pls notify after edit check output in playground, you can find what is wrong... Bart Mertens 1) don't put any argument to input() in code coaches, unless asked.. x = input() 2) Second input also needed, take into a variable. y = int( input() ) # input is int type so convert to int. your code y=int(3) is same as y=3 but you need to accept number as input here as above.. 3) print(x*y) #āˆšāˆš
10th Feb 2022, 6:34 PM
Jayakrishna šŸ‡®šŸ‡³
+ 1
G'day Bart Mertens the key information that you are missing: the variables need to be able to change with each test case. Test case 1 might input x as "cool", y as "2", output is "coolcool". Test case 3 will be something different. Your code needs to perform to the task description, not just force the individual test case. Can you think of a way to take the input x and input y each time the code is run?
10th Feb 2022, 6:55 PM
HungryTradie
HungryTradie - avatar
+ 1
I fixed it, thanks a lot you guys. This took me way to long. x="hi" y=3 x=input() y=int(input()) print(x*y)
10th Feb 2022, 7:07 PM
Bart Mertens
0
#Your first 2 lines are not needed. Just use x=input() y=int(input()) print(x*y)
10th Feb 2022, 7:16 PM
Jayakrishna šŸ‡®šŸ‡³
0
G'day again Bart Mertens That should work. You don't need to assign the variables to values, just to inputs. Debugging: Could you try to comment out the first two lines (Python interpreters ignore comment lines). Commenting is better than deleting because you get to see what you have tried, and because you can reinstate the code by deleting the comment marks. Change to: #x="hi" #y=3 Then you can see how it still works.
10th Feb 2022, 7:19 PM
HungryTradie
HungryTradie - avatar