Answer the question
In order to leave comments, you need to log in
How to split string for dictionary?
There is a line 455123-12412412-12414
, how to "stick" it into the dictionary, so that the first 6 values are the key. The rest, respectively, the value ?
Answer the question
In order to leave comments, you need to log in
bool is_clicked = false;
onclick() {
if(!is_clicked)
{
animate()
} else
{
search()
}
}
s = '455123-12412412-12414'
my_key, my_value = s.split('-',1)
my_dict = {my_key:my_value}
print(my_dict) #{'455123': '12412412-12414'}
s = '455123-12412412-12414'
my_dict = {s[:6]:s[7:]}
print(my_dict)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question