+ 1
is there an easier way to write this code?
x= input() count=0 for i in x: if i.isalpha() or len(x)!=5: count+=1 if count==0 : print("true") else: print("false") #i actually wrote this code for zip code validator and i was wondering how can i code it in an easier way cuz i think this is too complicated for it. at least thats how i think :))
2 odpowiedzi
+ 7
You don't need to use a loop here. Simply check len( x ) == 5 and x.isdigit() yields true.
Print 'true' when both conditions are satisfied, 'false' otherwise ...
+ 2
tnx alot :D