Alexander Richmond
Alexander Richmond

Reputation: 17

How do I remove letters from Key in python dictionary

i want to output the first three letters of each key and in all caps.
i have :

bulbs = { 'DAFFODIL': 0.35, 'TULIP': 0.33, 'CROCUS': 0.25, 'HYACINTH': 0.75, 'BLUEBELL': 0.50}

i have tried

for keys in m_order.keys():
    m_order[keys.split(2)]

how do I get this:

DAF
TUL 
CRO

Upvotes: 2

Views: 24

Answers (1)

High-Octane
High-Octane

Reputation: 1112

for keys in m_order.keys():
    print(key[:3].upper())

Upvotes: 1

Related Questions