+ 2

help with zip code coach improvement

Hi, i passed the tests but this answer doesnt feel good...ideas? Thanks! This is for the "code coach" zip code problem zip = input() if zip.isdigit and len(zip) == 5 and ' ' not in zip: print("true") else: print("false")

12th Apr 2020, 6:02 PM
Brenner Pieszak
Brenner Pieszak - avatar
5 Answers
+ 3
if zip.isdigit()
12th Apr 2020, 6:31 PM
HonFu
HonFu - avatar
+ 3
You forgot ().
12th Apr 2020, 6:34 PM
HonFu
HonFu - avatar
+ 2
isdigit is a method. You need to call this method, then it will check if the string contains only digits. If you just write... if 'word'.isdigit: ... ... then you basically only ask: Does the method isdigit exist? (It does.)
12th Apr 2020, 6:38 PM
HonFu
HonFu - avatar
0
what do u mean sir?
12th Apr 2020, 6:33 PM
Brenner Pieszak
Brenner Pieszak - avatar
0
oh, it still passed without it, what will the () do, and what did not having them do? Thanks!! i thought the parenth was only to specify if it was a certain dig
12th Apr 2020, 6:35 PM
Brenner Pieszak
Brenner Pieszak - avatar