+ 1
How could I use input() without I have to enter the result ?
hello I'm searching a means to actualize an input every time in order to answer to the computer quickly. sorry for my bad English thanks
18 Respostas
+ 3
OK try this
while True:
try:
x=int(input("enter x"))
#what you want to do
print("you entered"+str(x)) #im doing it
except keyboardinterpreterror:
break
it will ask you input every time and will return print data and if you press any key on keyboard it will stop
+ 2
Sun I'm sure that could work but unfortunately my python don't know keyboardinterpreterror.. and internet too! But this is the kind of function that will help me
+ 1
create a function .. which will give in input..
and after that call that every t milliseconds by using callbacks
+ 1
print([input("what number do you want to add? ") for i in range(int(input("how many numbers do you want to add?")))])
+ 1
Okay I just understood what you wanted,
print(input("enter your text with spaces between different words").split())
+ 1
Badmephisto your print function just put my input in a list but I have to press enter yet
+ 1
you don't want to press enter any time?? did you try putting spaces between your words though.
0
I'm sorry but I don't understand how I can create a function with an input because the function will stop immediately no? thanks
0
it's called self-nesting
def give_input:
print "Doing stuff..."
# do your stuff like giving inputs
give_input #again same function will be called
give_input
0
no module to import? I have no idea that exist. I just know recursive function! I will try it
0
that's in basics you don't any other module..
you will need other modules if you want to have some time gap between each inputs
like this
import sched, time
s = sched.scheduler(time.time, time.sleep)
def putInput:
print "Doing stuff..."
# do your stuff
s.enter(60, 1, putInput)
s.enter(60, 1, putInput)
s.run()
0
ok I have tried your first function like this
def give_input():
print ("enter a number")
u = input()
give_input()
and as I thinked the program stopped to wait my answer
0
Okay what kind of inputs you'll put in?
0
define an array of answers/inputs let's name it "answers"
define variable for answer number
let's say x=0
def give_input():
#print ("enter a number")
u = answers[x] #give in input
x++ #increment the value of x to get to next answer
give_input()
give_input()
0
I'd like to input number to move a charachter in an array but I'd also like that I mustn't push enter
0
I understand your function but how can the computer ask an answer because in your function there is any input()
0
thanks you badmephisto but your print function wait an enter
0
yes it is badmephisto and I don't understand what space between input could change that