Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to write a correct python code

d = {'hello': 'world'}

print(d.get('hello', 'default_value')) # prints 'world'
print(d.get('thingy', 'default_value')) # prints 'default_value'

# Or:
if 'hello' in d:
    print(d['hello'])
Source by docs.python-guide.org #
 
PREVIOUS NEXT
Tagged: #write #correct #python #code
ADD COMMENT
Topic
Name
5+6 =