Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Add missing person on list with default age 30
#python 3.5.2 #python 3.5.2 # List of strings my_list = ['john', 'james', 'joey'] # List of dictionary results = [{"name": 'john', "age": 20}, {"name": 'james', "age": 25}] # This is my code and its wrong. for name in my_list: found = False; for person in results: if person["name"] == name: found = True if not found: new_person = { 'name': name, 'age': 30 } results.append(new_person); print(results)
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Convert String to Lower Case
H.W.5 ALL Solutions
linked_lists_2+decisions
library
правильные окончания
Homework exercise
list_copy_shallow_deep.py
ok
26.09.2018
Organizing Transactions
Please log in to post a comment.