Nik18
March 4, 2026, 8:52pm
1
Не розумію в чому проблема. “Build a Medical Data Validator” Python project, Step 44
for index, key in enumerate(invalid_records):
val = dictionary\[key\]
print(f"Unexpected format '{key}:{val}' at position {index}.")
is_invalid = True
Що не так. Чому не працює код?
dhess
March 4, 2026, 8:58pm
2
Please post a link to the challenge. Thank you.
I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add the backticks.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').
dhess
March 4, 2026, 9:09pm
3
for index, dictionary in enumerate(data):
You are writing your code inside this loop, so you already have the index available.
Please make sure your f-string matches the text in the instructions, including the spacing.
Nik18
March 4, 2026, 9:25pm
4
dhess:
I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.
```for key in invalid_records:
val = dictionary[key]
print(f"Unexpected format’{key}:{val}'at position {index}")
is_invalid = TrueYou can also use the “preformatted text” tool in the editor (</>) to add the backticks.
dhess:
I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add the backticks.
```for key in invalid_records:
val = dictionary\[key\]
print(f"Unexpected format'{key}:{val}'at position {index}")
is_invalid = True
Витрачено пів дня не зрозуміло на що.
dhess
March 4, 2026, 9:31pm
5
Does the spacing in your f-string match the text in the instructions?
Nik18
March 4, 2026, 9:49pm
6
print(Unexpected format '<key>:<val>' at position <index>.)
OK. Code with this string format also doesn’t work
dhess
March 4, 2026, 10:04pm
7
I don’t see a space after the word ‘format’ or after the colon or after the last single quote.
Again, here’s the string from the instructions. Try copying and pasting it in your code and just replacing the angle brackets with curly braces.
Unexpected format '<key>: <val>' at position <index>.
Nik18
March 4, 2026, 10:17pm
8
Thanks for the tip. Finally I found the problem. There were several of them. Little things that take up a lot of time and discourage further learning.
system
Closed
April 1, 2026, 10:18pm
9
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.