key_list = ["name", "hp", "mp", "level"]
value_list = ["Articles", 200, 30, 5]
character = {}
for key in key_list:
for value in value_list:
character[key] = value
print(character)
I entered it like this.
The result value is {'name': 'article', 'hp': 200, 'mp': 30, 'level':5}
I want to come out like this.
The book says to use the string length I'd like to print it out using a double for statement.
But if you run that code, the keys go in order well, but I wonder why the value is only 50,000 for each key.
Also, please make it look like the result.
for key, value in zip(key_list, value_list):
You can do it like this.
The problem with the question code can be easily understood by turning it around as below.
for key in key_list:
for value in value_list:
character[key] = value
print(character)
© 2025 OneMinuteCode. All rights reserved.