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?

25th Jan 2023, 10:19 AM
MEh
MEh - avatar
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.
25th Jan 2023, 10:30 AM
DavX
DavX - avatar
+ 1
Update: I didn’t account for spaces.
25th Jan 2023, 10:22 AM
MEh
MEh - avatar
+ 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")
25th Jan 2023, 10:26 AM
DavX
DavX - avatar
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”
26th Jan 2023, 3:40 AM
MEh
MEh - avatar