Skip to content
Advertisement

Tag: for-loop

How do you eliminate items from nested lists

Given a list of ranked ballots and a list of candidates to eliminate, I need to return a new list of ranked ballots where all the candidates in the list of candidates to eliminate have been removed. This is the code I’ve tried so far My first doctest is failing, giving me this output instead: Answer This is the function

how to scrape all items of a page using a loop

i’m trying to scrape and list 24 items from a certain website. instead, it shows the same item 24 times. to get the first price i did this: as said, it does print 24 lines. but instead of listing all the different ones, it just lists the first result (probably because the i = 0). i’m very bad at coding

Series Summation using for loop in python [duplicate]

This question already has an answer here: How does the Python for loop actually work? (1 answer) Closed 3 months ago. Let’s assume this series in c with for loop we can easily done this in python i am able to done this using while loop but i can’t do it using python for loop Answer Python syntax is a

Find common characters between two strings

I am trying to print the common letters from two different user inputs using a for loop. (I need to do it using a for loop.) I am running into two problems: 1. My statement “If char not in output…” is not pulling unique values. 2. The output is giving me a list of individual letters rather than a single

Why isn’t my for loop working for my expression?

I want this function to read a password, and check to see if it has at least 1 number in it. If not, it needs to return False. I need to use a for loop with the range function and this is what I have: I’ve tried different variations and it’s driving me crazy. Can someone possibly explain to a

Advertisement