In my comp sci class, we’ve just touched on dictionaries. I’m trying to figure out how to remove an item from a list in a dictionary and move it to another list.
For example,
dict1={ 'colors':[red,blue,green], 'sweaters':[mine, his, hers]}
Let’s say I wanted to check if “red” was in the dictionary, and it was. So how could I go about removing it from “colors”, and adding it to “sweaters”? The list part has thrown me off.
This is the function I have thus far( the actual problem)
`def nowRead(yourDict, title):
key1, key2, key3, key4 = yourDict.values()
if title in key2:
key2.remove(title)
key3.append(title)
return yourDict
1 Answer