I want to take integer input in python within a range how do i do that? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

I want to take integer input in python within a range how do i do that?

python 3, input

10th Mar 2018, 3:06 PM
Somnath Mahato
Somnath Mahato - avatar
3 Réponses
+ 5
# First, define a variable. x = input("Enter a number in the range m to n: ") # Then, define a range for variable x using while loop while(x < m or x > n): x = input("Re-enter a number in the range m to n: ") # Therefore, while loop will end when x will come in the specified range! # Better to use Python 3, cuz in SL editor, re-input never works ;)
10th Mar 2018, 3:39 PM
777
777 - avatar
0
Thank you so much Blue, However, there is no way to take the input in a range at once?
11th Mar 2018, 11:43 AM
Somnath Mahato
Somnath Mahato - avatar
0
I want to take input in the range 1-100 how do I do that?
11th Mar 2018, 11:46 AM
Somnath Mahato
Somnath Mahato - avatar