First of all, you shouldn't use input. Python parses input as python code not as text. So someone can actually enter python code into the input.
Second, avoid using names like dict and list for your variables, as this is what python uses for the dict and list objects and you are creating a conflict.
Here's an example of how you can achieve what you want:
Code:
my_list = ['A', 'B', 'C']
results = {}
for x in my_list:
results[x] = raw_input("Enter grade for %s: "%x)
print results
As far your second question goes, dict[x].append calls the append method of the value of dict[x]. That means that dict[x] will have to be a list in order for you to call it. You would normally use dict[x] = value. If you want to modify an item and have a default value in case the item doesn't exist, then you could use dict.setdefault:
Code:
>>> ex_dict = {}
>>> ex_dict['bcd'] = ['b', 'c', 'd']
>>> ex_dict['bcd'].append('d')
>>> ex_dict
{'bcd': ['b', 'c', 'd', 'd']}
>>> ex_dict['abc'].append('c')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'abc'
>>> ex_dict
{'bcd': ['b', 'c', 'd', 'd']}
>>> ex_dict.setdefault('abc', ['a', 'b', 'c']).append('c')
>>> ex_dict
{'bcd': ['b', 'c', 'd', 'd'], 'abc': ['a', 'b', 'c', 'c']}
>>>
Note that ex_dict['bcd'].append is essentially calling append on the item 'bcd' of ex_dict (which is a list). Since this is a list, we can actually call append. When ex_dict['abc'] is not defined, then append gives us an error.
So we use ex_dict.setdefault('abc', ['a', 'b', 'c']).append('c'). What this does is it checks to see if abc is a key in ex_dict. If it isn't it sets ex_dict['abc'] = ['a', 'b', 'c'] and then allows to further manipulate the item. If it is already set, it lets us manipulate it, without actually setting it to ['a', 'b', 'c']. That's why this doesn't work:
Code:
>>> ex_dict['abc'] = 'abc'
>>> ex_dict.setdefault('abc', ['a', 'b', 'c']).append('c')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'append'
>>>
Since abc is already set to a string, which doesn't have an append method, you cannot call append. If abc wasn't set, then setdefault would set it to a list and then you can use append.