Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Simple dictionary in Python

import string

# Edited by Sadman Sakib

dic = {'greet': 'something that you say or do to greet somebody',
       'sleep': ' [intransitive] to rest with your eyes closed and your mind and body not active',
       'morning': 'The early part of the day from the time when people wake up until 12 o'clock in the middle of the '
                  'day or before lunch',
       'noon': '12 o’clock in the middle of the day',
       'night': 'the time between one day and the next when it is dark, when people usually sleep',
       'evening': '[countable, uncountable] the part of the day between the afternoon and the time you go to bed'}

words = []  # for printing a welcome message
dic_keys = list(dic.keys())
for i in dic_keys:  # displaying upper case of lowercase words
    x = i.upper()
    words.append(x)  # appending in words variable

print('Welcome to Dictionary!
'
      'Here is a list of variable words which you can search', words)

user_input = input('Enter a word for search: ')
dic_search = user_input.lower()  # converting into lowercase

output = dic[dic_search]  # searching on dic

print(user_input, 'means: ', output)

Comment

PREVIOUS NEXT
Code Example
Python :: handle 404 in requests python 
Python :: how to create adjacency matrix from adjacency list in python 
Python :: python functions with input 
Python :: python slice notation 
Python :: open file in python directory 
Python :: numpy rolling average 
Python :: python fill zeros left 
Python :: how to get local ip in python 
Python :: fillna with median , mode and mean 
Python :: Python numpy.broadcast_to() Function Example 
Python :: python b string 
Python :: how to restart loop python 
Python :: stack concatenate dataframe 
Python :: php echo shorthand 
Python :: matplotlib vertical tick labels 
Python :: django get_user_model() function 
Python :: merging df vertically 
Python :: python datetime get weekday name 
Python :: pandas xa0 
Python :: python smtp sendmail 
Python :: roblox api python 
Python :: check if string contains python 
Python :: print colored text in python 
Python :: python fractions 
Python :: soup itemprop 
Python :: split into list into even chunks 
Python :: planets code 
Python :: transpose of list in python 
Python :: maximum and minimum value of array python 
Python :: Flatten List in Python Using NumPy Flatten 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =