Table = u'''A,This is A
B,This is B
C,This is C
D,This is D
E,This is E
F,This is F
G,This is G
H,This is H
I,This is I
J,This is J'''
SearchValue = u'''A
B
C
D
Bang
F
Bang
G
H'''
Table = Table.splitlines()
LineText = {}
for targetLineText in Table:
LineText[targetLineText.split(',')[0]] = targetLineText.split(',')[1]
SearchValue = SearchValue.splitlines()
for targetValue in SearchValue:
print LineText[targetValue] if targetValue in LineText else 'Error:' + targetValue
What this code is doing is... It finds value lists from the 'Table' dictionary by keys called 'SearchValue'
I check if the key exists by the following code..
targetValue in LineText
What I want to do to get the value at the same time of the key value existing check. Because I think that performs better.