+ 1

Conditional Python input

How can we execute statement from while loop which is conditioned with input function in Python, that is looped until you get input in runtime

20th Feb 2018, 7:00 AM
Deepak
Deepak - avatar
5 odpowiedzi
+ 1
so you want x process to run while you see the input question on screen? There is no simple way to do this, not even using threading(works if assumed input is a single keypress) since the while loops multiple times per second and every loop refreshes the input dialog, such only single keypress is valid option. You might be able to do this with a more complex OOP code but not in a simple way
20th Feb 2018, 2:02 PM
Markus Kaleton
Markus Kaleton - avatar
+ 4
Loop is like a staircase,you can use it up to the usable part,if a 6 stroyed building has Staircase up to 4th floor,then you can go up to 4th floor,but if your desired destination is 3rd floor,then you stop on 3rd floor,though you can move up to 4th floor,if your destination is 6th floor then you cancel your journey at the beginning or not start your journey. If the building has Staircase up to 6th floor then you can move as many times as you wish or for unlimited time. Please read my simple example here: https://www.sololearn.com/discuss/1086266/?ref=app
20th Feb 2018, 8:17 AM
📈SmileGoodHope📈
📈SmileGoodHope📈 - avatar
+ 2
loop should stop if it has no entered one in input()
20th Feb 2018, 8:22 AM
Deepak
Deepak - avatar
0
do you mean something like this? while True: answer = input("something") if answer != "" break didnt test the integrity of that code but i think you get the gist of it
20th Feb 2018, 8:35 AM
Markus Kaleton
Markus Kaleton - avatar
0
replace true with input, i mean this. @Markus
20th Feb 2018, 12:55 PM
Deepak
Deepak - avatar