Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Add missing persons
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#python 3.5.2 #python 3.5.2 # List of strings my_list = ['john', 'james', 'joey'] # List of dictionaries results = [{"name": 'john', "age": 20}, {"name": 'james', "age": 25}] 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)
[
+
]
Show input
Absolute running time: 0.15 sec, cpu time: 0.13 sec, memory peak: 6 Mb, absolute service time: 0,16 sec
edit mode
|
history
|
discussion
[{'age': 20, 'name': 'john'}, {'age': 25, 'name': 'james'}, {'age': 30, 'name': 'joey'}]