With the string variable being:
text = 'red~5~cat'
I would like to split it by '~' character and store the values as a dictionary. I have reserved the names for the keys and they are:
key_names = ['color', 'number', 'pet']
I wonder if there is a way to pack the result of splitting as a dictionary below?
{'color':'red', 'number':5, 'pet':'cat'}