+ 4

Need help with a code

Hi, I've been struggling with this code for pratice 15.3 of python and i would appreciate it if u guys can help me out. Have tried different solutions but cant seems to solve it. Heres the question: Given the code above, output the input x repeated y times. Sample Input: awesome 3 Sample Output: awesomeawesomeawesome This is the code that i use: x = input("awesome") y = int(input("3")) print(x*y) Would gladly appreciate if u guys can help me out here. Keeps getting an error on this code

30th Mar 2021, 3:32 PM
Zhi Hong
Zhi Hong - avatar
18 Respostas
+ 9
Somebody wrote code to take a string input and output it, repeated 10 times. However, the code results in an error. Fix the code to output the desired output. so simple , x = input() print(x*+10)
8th Oct 2021, 8:30 AM
Vandana
+ 4
Try without the prompt strings like this: x = input() # read something like awesome from the user. y = int(input()) # read something like 3 from the user. print(x*y) Passing a string to input causes it to print the string as if it is prompting the user for something specific. That probably causes the automated tests to fail since the output of: awesome3 awesomeawesomeawesome is not exactly the same as just: awesomeawesomeawesome If you run that as Python in Sololearn's Code Playground, just put this in the initial popup: awesome 3
30th Mar 2021, 3:36 PM
Josh Greig
Josh Greig - avatar
+ 2
Josh Greig Olga oh i get it now. My bad i didnt understand when u tried to explain why not to put in any parameters but now i understand. Thank you both so much
30th Mar 2021, 4:18 PM
Zhi Hong
Zhi Hong - avatar
+ 2
x=input () y=int(input()) print(x*y)
31st Mar 2021, 1:26 PM
Khondamir Rustamov
Khondamir Rustamov - avatar
+ 1
Haider wrote, "In python X = input("") Y = input("") Print(X*Y)" Response: Haider, that won't work. input returns a string even if it is a "3" and "awesome" * "3" would result in error. Case is wrong for Print. It needs to be print. Try it out for yourself and you'll see.
1st Apr 2021, 2:56 AM
Josh Greig
Josh Greig - avatar
0
Good afternoon! In your code, your input looks like this: input ("awesome"), int (input ("3")). When you run it, your program will print these lines. Basically, when you add something within the input parentheses, it is a hint for the user what to enter. The testing system does not need these hints; it only checks what the programs output. For a testing system, the output in your program looks like this: awesome 3 awesomeawesomeawesome Remove everything from the parentheses at the input, and the program should work correctly. x = input() y = int(input()) print(x*y) Hope this helped!
30th Mar 2021, 3:42 PM
Olga
0
Josh Greig Olga Hello there, and thank you for your help, but when i do that i get an error that says undefined variable awesome and im really confused by it
30th Mar 2021, 3:53 PM
Zhi Hong
Zhi Hong - avatar
0
zhi Hong, could you please share your code? By the way, did you try to send the code I added? There should be no problems with variables.
30th Mar 2021, 3:56 PM
Olga
0
Zhi wrote, "x = input(awesome) y = int(input(3)) print(x*y)" Response: No. Remove the 3 and awesome there. Copy exactly what I shared. I added a comment only to explain. My comment wasn't asking you to add any parameters to the input function. Here is what I shared again: x = input() # read something like awesome from the user. y = int(input()) # read something like 3 from the user. print(x*y)
30th Mar 2021, 4:14 PM
Josh Greig
Josh Greig - avatar
0
Wow i did it simple print(x * 10)
16th Nov 2021, 4:06 PM
Mante Joseph
0
Somebody wrote code to take a string input and output it, repeated 10 times. However, the code results in an error.
10th Jan 2022, 7:24 AM
Jay Patel
0
X =input() Print(x*10)
13th Jan 2022, 12:59 AM
KEERTHANA R
0
Test Case 1 x = "hello print(x*10) -----> no Problem Test Case 2 -----> OMG!!! HELP!!!
19th Feb 2022, 6:10 PM
Armando López Rodríguez
Armando López Rodríguez - avatar
0
Solved x = input() print(x*10) That's it
19th Feb 2022, 6:16 PM
Armando López Rodríguez
Armando López Rodríguez - avatar
0
i've been trying, i can do the the answer just like that.. BOOM x = input('') print(x*10)
3rd Mar 2022, 6:29 AM
Abednego Eka Chandra
- 1
In python X = input("") Y = input("") Print(X*Y)
31st Mar 2021, 2:09 PM
Haider ali
Haider ali - avatar
- 2
Olga i have inputed ur code this way: x = input(awesome) y = int(input(3)) print(x*y) Not sure if this is what you mean? But i have gotten thr undefined variable when i key it in this way. Maybe im doing it wrong somewhere?
30th Mar 2021, 4:01 PM
Zhi Hong
Zhi Hong - avatar