My solutions have sooo many lines of code :)
My solution:
def is_valid_zip(zip_code):
"""Returns whether the input string is a valid (5 digit) zip code
"""
zip_len= len(zip_code)
for l in zip_code:
if l.isdigit() == False:
return False
if zip_len == 5:
return True
return False
VS suggested :
def is_valid_zip(zip_code):
return len(zip_code) == 5 and zip_code.isdigit()
2
2 comments
Kevin Cranfield
3
My solutions have sooo many lines of code :)
Data Alchemy
skool.com/data-alchemy
Your Community to Master the Fundamentals of Working with Data and AI — by Datalumina®
Leaderboard (30-day)
Powered by