Skip to content

Tag: list

Using filter and lambda in a list of lists

I working with a list of lists. Each of those lists are the same — they contain title, url and some additional statistics (always in the same order). I would like to create a function find_title, which takes the wanted title and returns the whole list (with title, url and statistics). That’s my at…

Find the percentage of coin streaks

I’m trying to write a program to find out how often a streak of six heads or a streak of six tails comes up in a randomly generated list of heads and tails of 100 flips and repeat this 10000 times to find percentage of the coin flips contains a streak of six heads or tails in a row. My

How can I replace items within a list in python3 using a condition?

Write a function which prints all integers between 0 and 100: For every number that is divisible by 7 or has the digit 7 print ‘boom’ instead of the number itself. My solution so far: print(boom()) Helped by: AkshayNevrekar Question: Do you find a better way to solve this specific problem? a better algorithm?…

Output Common Elements of Two Lists using Sets

I’d like to write a function definition that takes two lists and returns a single set with the values that each list has in common. Formally, here are some assertions I’d like to pass: Here’s the code I’m having trouble with: I receive an error output that I know has to do with strings…

Find all the minimal values on a list

I have a list of tuples. Each tuple’s element 0 is a numeric value. I want to find all the tuples with the minimal value in element 0. For example: would give me what I want: My question is (could be three different answers): what is the Code Golf/fastest/most Pythonic way to do this? Answer Here’…