0
Hello,I'm on the exercise of working with input, someone can tell me why this is not accepted? x=str("hi") y=int(3) print(x*y)
Working with input
60 Respuestas
+ 8
Is the exercise named "Working with input"? Possibly you need to use the input() statement to read one or more of the values.
Take note: "hi" is already a string. The quotation marks define it as a string. It is redundant to convert it to string with the str("hi") function. Likewise, 3 is already an int, since it does not have quotation marks, so y = 3 is enough.Though, if y is taken as input then the input will need to be converted to int. That is because input() returns a string. It would look like this: y = int(input())
+ 6
Marco Grotto hard coding is you are giving value to variable.. instead of getting it as user input
+ 3
Hello, you should just write x="hi"
Or if you wanna something different write
x=input() so then you can work with a string ✨
Also you should write y=3
Or if you wanna something different write
y=int(input())
so then you can work with a integer number ✨
+ 2
What error message it is showing can you clarify?
+ 2
Marco Grotto is either of one case only passed for you?
+ 2
Try this way:
x = input()
y = input()
print(x*int(y))
+ 2
x=input ()
y=int(input())
print(x*y)
This is working fine in pc . May be in solo learn it's not allowed to input more than one input.
in this code you have to first input string which you want multiple times and then input how many times do you want to print that string.
+ 2
Marco Grotto from your question you post,
First input should be a string
Second should be integer
So,
A=input()
B=int(input())
Print (A*B)
It will work...
+ 2
Michael Wambua how string can print any string multiple times?
+ 2
Avinash Kumar thanks that finally work, but what is hard coding?
+ 2
Marco Grotto hard coding means you already take variable value just like x="hi" and y=2 or any number. But in soft coding user gives value through input function
+ 2
Okok thanks, now I get it
+ 1
Marco Grotto it is accepted only run the code and see...it's working
it prints hi 3 times
+ 1
Then don't declare the input yourself...get it as user input
+ 1
x=str(input())
y=int(input())
print(x*y)
like this
+ 1
It's quite hard may be there is mistake in question
+ 1
Marco Grotto can you screenshot the question and post it here..may be you missed something in it
+ 1
Riya your code is showing error in this platform