I have created a dictionary in python as my first 'major' project. I'm using it to keep track of key words as I go along. The entered are just examples so feel free to improve my definitions (:
I'm new to python so feel free to criticise my technique so I can learn before it gets any worse!
What I'm wondering is, would there be a way to deal with searches that are not included in the dictionary.
As in 'Sorry, the word you were looking for could not be found, would you like to try another search?'
Anyway, here's my code:
Running = True
Guide = {
'PRINT': 'The function of the keyword print is to: Display the text / value of an object',
'MODULO': 'The function of Modulo is to divide by the given number and present the remainder.'
'\n The Modulo function uses the % symbol',
'DICTIONARY': 'The function of a Dictionary is to store a Key and its value'
'\n separated by a colon, within the {} brackets.'
'\n each item must be separated with a comma',
'FOR LOOP': 'The For Loop uses the format: \n '
'For (variable) in (list_name): (Do this)',
'LINE BREAKS': ' \ n ',
'LOWERCASE': 'To put a string in lower case, use the keyword lower()',
'UPPERCASE': 'To put a string in upper case use the keyword upper()',
'ADD TO A LIST': 'To add items to a list, use the keyword: .append'
'\n in the format: list_name.append(item)',
'LENGTH': 'To get the length of a STRING, or list use the keyword len() in the format: len(string name)', }
while Running:
Lookup = raw_input('What would you like to look up? Enter here: ')
Lookup = Lookup.upper()
print Guide[str(Lookup)]
again = raw_input('Would you like to make another search? ')
again = again.upper()
if again != ('YES' or 'Y'):
Running = False
else:
Running = True