Skip to content

Tag: list

How to remove str. Of spaces from list [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 1 year ago. Improve this question A = [&…

How do I iterate over two lists?

I have troubles in using for loops in Python. I wrote this code: and the output is: But I would like the output to be: Is there a way to make the for loop iterate over first “Mary” and “she” and then “Joe” and “he” ? I thank you in advance. Answer Why, you can g…

python: get percentage from collection counter

I have two lists like the following: I have tried to get the counts of elements in the first list based on a condition: the output is: instead of counts, I would like to get their percentage like the following I have tried adding Counter(100/([a for a,b in zip(l1,l2) if b==’f’])), but I get an err…