Login
|
Signup
langref.org
-
python
add..
all
clojure
cpp
csharp
erlang
fantom
fsharp
go
groovy
haskell
java
ocaml
perl
php
ruby
scala
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Maps
Access
Check if a key exists in a map
Given a map pets
{joe:cat,mary:turtle,bill:canary}
print
"ok"
if an pet exists for
"mary"
python
pets = dict(joe='cat', mary='turtle', bill='canary')
if ("mary" in pets) print "ok"
pets = dict(joe='cat', mary='turtle', bill='canary')
if ("mary" in pets) print "ok"
Submit a new solution for
python
There are 27 other solutions in
additional
languages (
clojure
,
cpp
,
erlang
,
fantom
...)