+ 7
Why it gives an error?
Because none is used to represent the absence of a value. s=int(input()) if s==None: print("Please write something") (Note:- I don't want to use assertions here)
8 odpowiedzi
+ 1
I already added explanation for this also.. Refresh page.
Hoping here you taking about on "nothing input". Then that is equal to none or "" (empty string).
You can assign these to values to variable in python..
In that code also int(input1) raise error if input is none or if not a number. ꧁༒Rishabh༒꧂
+ 4
Special Thanks to all
My doubt is clear now..
+ 3
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥
Didn't understood clearly and can "None" here cannot be used?
+ 3
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥
Gordon's answer I can understand of 1st version.
But I didn't get the 2nd one.
Which line is preventing to not reach.
+ 3
Jayakrishna🇮🇳
Then, how does this works?
Because you said it's not reached there(getting confused)
input1=input()
if len(input1)==0:
print("Input1: Please enter a value")
elif int(input1)>=1001:
print("Input must be less than 1000")
else:
print("Input1 :",input1)
+ 2
꧁༒Rishabh༒꧂
What error you mean..?
S = int(input())
In this if you don't input a number, then it raise exception itself. Don't go to compare statement.
On no input, internally for none:
int(none) is value error there... Hence again error also.
But s = input()
if s == None :
Will work because variable accept none value.
+ 1
basically, when you call for an integer input, the input can only include a number.
but if you call for regular input:
-you can check isdigit
-you can take regular strings and stop when a certain string is put in
-if the string meets certain criteria it can be converted to int