0
Don't understad test case multiply variables
Hello! I havet a problem test case #1 & #2 in multiply variables. Test case #1 is input 1: hi, and input 2: 5. And the output should be hihihihihi. So I wrote x = "hi" y = int("5") print(y*x) No problems there, in test case #2 is input 1: python and input 2: 3. And the output should be pythonpythonpythonpython. So I wrote: x = "hi" y = int("5") print(y*x) x = "python" y = int("3") print (x*y) But then the answere is: hihihihihi pythonpythonpythonpython And I get wrong answere on both test cases. So to my question, how do I sepperate thise two so I get right on both?
3 Answers
+ 1
You have take two input, first one string input and the other one integer input and assign it to two variable then multiply the string input with integer input and print it.
Try this one:
string = input()
num_to_multiply = int(input())
result = string * num_to_multiply
print(result)
+ 1
Go through this to understand input function π
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2426/
+ 1
Thanks a ton!!
And thanks for the link!