+ 3

Input in Loop (Python)

Hey can anyone Tell me How i can ask for various Input in a Loop?? I thought it should work like this: for i in range(5): input = input() print(input) But this doesnt work apparently:/ Thanks in advance✌🏼

14th Apr 2019, 10:15 PM
Bredator
6 Réponses
+ 6
1. It is not recommended to use functions (e.g. input) as variable names as it can mess up with your code. 2. All inputs must be entered before the code is executed (that's the way it is with non web languages on SoloLearn). Try entering this as input (in separate lines). hello darkness my old friend
14th Apr 2019, 10:24 PM
Diego
Diego - avatar
+ 5
You can take multiple inputs using this statement : x,y,z=[int(x) for x in input("Enter values").split()] This is use to take all the inputs in one line
15th Apr 2019, 1:27 PM
Prince PS[Not_Active]
Prince PS[Not_Active] - avatar
+ 4
The code will run as far, as the user types the input. So if the user doesnt anything, your code will stuck at the same point. I underdtand what you mean, but i dont really know, sorry.. However, on sololearn its only possible to take at least 1 input, because here, the person can either see the input field, or the Console.. So it dont makes really much sense😉 I Hope that i could help you😊💛
15th Apr 2019, 5:54 PM
I‘m Sarah🌹
I‘m Sarah🌹 - avatar
+ 3
Agree with above. input is a variable storing a function. By overriding with your own definition, you are essentially getting rid of all the coding that went behind making the input function. I think that is what is wrong with your code.
14th Apr 2019, 11:39 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
thanks everyone. by now i lesrned that this problem only occurs on sololearn. and of course i would name it differently in a real code. sorry for the confusion✌🏼✌🏼
22nd Apr 2019, 7:50 PM
Bredator
- 1
For I in range(1,6): Print(append. Input[i])
15th Apr 2019, 9:46 AM
PRAVEEN KUMAR
PRAVEEN KUMAR - avatar