+ 1

Range is not stopping the amount of characters like it should?

Correct me if I'm wrong, but when inputting range like : range(x,y), x marks the starting point, and y where to stop. In my code, the starting point works perfectly, but my 'y' fails to stop anything. For example, if I input range(3,5), the numbers will start at 3, but will fail to end at 4 as it is supposed to. My code: a= input( "Enter any four digit number: ") if a.isdigit() and range(3,5): print (a) else: print ("Please try again.") What am I doing wrong?

11th Apr 2018, 2:52 AM
Robyn
1 Resposta
+ 4
The problem is range. Your input a is string type and if you want to use range then your variable must be an integer. One of the solutions : https://code.sololearn.com/cbayjRQ1IFMW/?ref=app
11th Apr 2018, 3:49 AM
voja
voja - avatar