I have a dataframe with 'key' and 'value' columns, I would like to input a key and get output a value.
import pandas as pd
df = pd.DataFrame({
    'key': ['A', 'B', 'C', 'D'],
    'value': [2, 8, 10, 12]})
print(df)
key = 'B'
value = df[df['key'] == key]['value']
print(value)
Current output as below:
  key  value
0   A      2
1   B      8
2   C     10
3   D     12
1    8
Name: value, dtype: int64
How can I get the output value: 8 in this case since the key is 'B'.
 
     
     
     
    