I will try to easily explain my problem. I have a dictionary that looks like this:
dic = {
'I2a1a': ['I2a1a2', 'I2a1a2a', 'I2a1a2a1a2'],
'I2a1b': ['I2a1b1a1a1b1a'],
'I2a1b2': ['I2a1b2a']
}
Based on this dictionary, when the length of the value is > 1 I want to create a new dictionary that will look like this:
new_dic = {
'I2a1a': 'I2a1a2', 'I2a1a2': 'I2a1a2a', 'I2a1a2a': 'I2a1a2a1a2',
'I2a1b': 'I2a1b1a1a1b1a',
'I2a1b2': 'I2a1b2a'
}
As we can see for the key 'I2a1a'
in the first dictionary, each value (except the last value) is a key in the new_dic
and the value associated with it is the index n+1
from the values of the key 'I2a1a'
of the first dictionary.
I have no idea where to start my script!