Skip to content

Tag: list

How to convert string of list of list to list?

I have this file, it is the result of the MapReduce job so it has key-value format: I want to remove all the character except the second element of this value list: And finally, add each to a single list: This is my attempt so far: Output: You can see it is still str type, how can I make it

What makes the difference by creating a set in this code?

Given a list of numbers and a number k, return whether any two numbers from the list add up to k. For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17. Bonus: Can you do this in one pass? I wrote my code like this and i got right answer for the above input And checked others code too …

Nested FOR loops – coding challenge

I am learning python using STEPIK and I am facing this: I want on every iteration of the inside for loop sum the values of predicted_growth list with the value of cases list, save it in some temporary variable and print it. Click on the link for the full challenge. This is my code so far: This is the output