0
I’m beginner and what’s wrong in this code
X=input (“hi”) Y=int(input (3)) Print (x*y) Output is hi I wanted to be hihihi
7 Réponses
0
# Hi! You can try this:
name = input("Input your name: ")
print()
n = int(input("The number of repetitions: "))
print()
print(n * (name + ", "))
+ 9
If you are referring to a sololearn code project:
DO NOT WRITE ANYTHING INSIDE THE INPUT FUNCTION.
x = input(), not x = input("hi")
and so on
Please check the spelling before you post your code.
+ 7
I would recommend removing the input function.
Try just doing
x = "hi"
y = 3
There's not real purpose in using the input function if you do not want outside user input and are okay with pre-declaring the word you would like to use.
+ 4
Mehrad Nejad
you should only use input method only when you want the to take user input otherwise don't use it.
input() 👈👈 only for taking input
and if you want to take user input and prompt a message for the user at the same time then you should use
input("your message") 👈👈
but if you want to just prompt a message then use
print("your message") 👈👈👈
+ 1
<<❗️PLEASE READ PROBLEM 2 FIRST❗️>>
1. Why don’t you write ‘y=3’ instead of ‘y=int(input(3))’? Try it! It would be much easier! (same problem with x)
2. No ‘int’ing integers because it’s already an integer. (btw ‘int’ means integer) So it will cause an error so python will ignore
the variable and DELETE the variable so it means ‘x(‘hi’)*y(deleted/ignored so it’s a ‘*1’), making the output ‘hi’.
0
The input(3)
gets user input and you already know your input to be 3
0
it should be like this
X ="hi"
Y =input("enter number")
Z =int(y)
if y ==none:
print("please enter input")
else:
print(X * Z)