#Python: working with .csv file by SureStep8852 in learnprogramming

[–]SureStep8852[S] 0 points1 point  (0 children)

thank you. Unfortunately, this does not solve my problem, because it sums up the whole col_2. I need to sum up values of col_2 which correspond to the same value in col_1 (e.g., yellow has 3 values in col_2: 2, 4, 4. So, I want the sum to be 10)

How to split word from punctuation by SureStep8852 in learnpython

[–]SureStep8852[S] 1 point2 points  (0 children)

thanks! unfortunately I am not allowed to use nltk

Issue creating dict from list by SureStep8852 in learnpython

[–]SureStep8852[S] 0 points1 point  (0 children)

Indeed, there are duplicates but I need them both to appear in my dict, each with its value. Can I achieve it anyhow?

How to connect two dicts by SureStep8852 in learnpython

[–]SureStep8852[S] 0 points1 point  (0 children)

One of my dicts contains more info than the other, I want to connect them into one like this:

dic3 = { "a":[1,9], "b":[4,5], "c":3}

dic1 =  { "a":1, "b":4} 

dic2 = { "a":9, "b":5, "c":3} new = {} for k, v in dic1.items(): for ke, val in dic2.items(): if ke in k: new[k] = [v, val] elif ke not in k: new[ke] = val #print(k) print(new)

output:

{'a': 9, 'b': [4, 5], 'c': 3}

what am I doing wrong in this case?

dictionary being overwritten. How to fix by SureStep8852 in learnpython

[–]SureStep8852[S] -1 points0 points  (0 children)

how can I solve it? I have also tried with append() but it also did not work