0
How is this easy?
Iâm trying to finish the Zip Code Validator challenge, but Test Case #3 doesnât seem to budge. The prompt is basically asking to make sure that there are 5 characters, and that each are numbers. My code: zip = input() numbers = ["0â, â1â, â2â, â3â, â4â, â5â, â6â, â7â, â8â, â9â] c = 0 for char in zip: if char in numbers: c += 1 if c == 5: print(âtrueâ) else: print(âfalseâ) Anybody see the issue?
4 RĂ©ponses
+ 2
...by dodgy quotation marks I mean:
Use " " : neutral, vertical, straight, typewriter, dumb, or ASCII quotation marks.
Not â â: typographic, curly, curved, book, or smart quotation marks.
+ 1
Update: I didnât account for spaces.
+ 1
Your code runs, when you remove your dodgy quotes - â7â for example should be "7"
zip = input()
numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
c = 0
for char in zip:
if char in numbers:
c += 1
if c == 5:
print("true")
else:
print("false")
0
Nice catch, but I only made that mistake because when I was manually retyping my code into this post, I forgot to change the quotes.
The main issue was resolved by adding:
if char == " "
c -= 1
Under âc += 1â