'How do i remove part of a key in a python dictionary

I want to only see the times in the dictionary as it it currently being printed like

dictionary

How do i only see, for example the 17:00 - 18:00 part of the dictionary.

event_dates = {} #dictionary to store event dates and time
df = pd.read_html('https://www.dcu.ie/students/events')[0]['Event date']
event_dates.update(df)

I have tried using the pop method but doesn't seem to work. this is how i am printing it

for key in event_dates.values():
     print(key)


Solution 1:[1]

You can do the following to print any desired key from the dictionary, just replace it with whatever time you need to print:

    for key, value in event_dates.values():
         if key == event_dates["March 9, 17:00 - March 9, 18:00"]:
             print(value)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Danny