0
Python Problem [Solved ✅]
I wrote a code that determines if the user wrote something or not using none, but when I typed nothing, it said that I wrote something. https://code.sololearn.com/c9DCc65MO06Z/#py
2 Réponses
+ 2
Inputting nothing does not means that the value of input is none. You can use the length of input.
user = input()
if len(user)==0:
print("Bruh, you wrote nothing! XDDDDDDDDDDDDD")
else:
print("OOH~! THANK GOODNESS! YOU WROTE SOMETHING!")
+ 1
input() will return an empty string ('') if nothing is entered. '' is not equal to None. It is however a falsy value, so, you can just say;
if user: # else block runs
Or
if not user: # if block runs
instead of;
if user is None:
Or
if user == None:
https://www.google.com/amp/s/www.geeksforgeeks.org/truthy-vs-falsy-values-in-JUMP_LINK__&&__python__&&__JUMP_LINK/amp/