KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'd like my dictionary to be case insensitive: text = "practice changing the color" words = {'color': 'colour', 'practice': 'practise'} def replace(words,text): keys = words.keys() for i in keys: text= text.replace(i ,words[i]) return text text = replace(words,text) print text Output = practise changing the colour I'd like another string, "practice changing the Color" , (where Color starts with a capital) to give the same output. I believe there is a general way to convert to lowercase using mydictionary[key.lower()] but I'm not sure how to best integrate this into my existing code.
Tags (comma-separated)
Save Edits
Cancel