Please HELP!! I have a list: I want to generate iteration number if it’s False the number continues and if it’s True the number stays. I Try this code: it’s just keep running and did not show any output. the desired output will be [1,2,3,3,3,4,5,6,6] I have no idea what’s wrong with it Thanks Answer Yet another version of this
Tag: for-loop
How to stop loop running out of memory?
I’ve come back to programming after a long haitus so please forgive any stupid errors/inefficient code. I am creating an encryption program that uses the RSA method of encryption which involves finding the coprimes of numbers to generate a key. I am using the Euclidean algorithm to generate highest common factors and then add the coprime to the list if
Why is print not printing my array sorted
This is my original array: a = [0, 4, 7, 8, 1, 3, 5, 2, 6] and this is what it prints: [0, 4, 7, 0, 0, 0, 5, 0, 0] Answer As @’Lee Jun Wei’ it doesn’t look like your algo is right. But there may be a few other things to point out. These two lines look off.
Buttons in a for loop to update labels in a for loop?
Trying to get individual buttons to update individual labels in tkinter. Here’s my code: When you run the code there are three buttons in a column next to three labels in the next column over. What I’m trying to do is get it so that each button changes the label next to it. What happens when I run the code
How to ignore numbers after specific number in the list/array in Python?
I’m stuck on this problem: I was trying to return sum of list of numbers in the array ignoring sections of numbers starting with a 6 and extending to the next 9 (every 6 will be followed by at least one 9). Return 0 for no numbers. Here are my test cases: I came up with something like: Answer i
web-scraping error message: ‘int’ object has no attribute ‘get’
Hello Stack Overflow contributors! I want to scrape multiple pages of a news website; it shows an error message during this step The error message is The lines of code are More specifically, this page and pages next to it are what I want to scrape: https://nypost.com/search/China+COVID-19/page/1/?orderby=relevance Any helps would be greatly appreciated!! Answer For me this code runs okay.
How to iterate through a nested for loop in pandas dataframe?
I am attempting to iterate through a Hacker News dataset and was trying to create 3 categories (i.e types of posts) found on the HN forum viz, ask_posts, show_posts and other_posts. In short, I am trying to find out the average number of comments per posts per category(described below). The results respectively are; 395976587 250362315 and 43328.21829521829 24646.81187241583 These seem
Python dynamic for loop range size
I’m trying to add Link argument to ini file by using python. Example of ini file: I need to do like this: My for loop: My code works, but it does not add Link for last tags. I’ve found why. If I add in range(len(m)+100): Then code adds all Links. Looks like len(m) is old value (static?), because I’m increasing
Automate the Boring Stuff – Chapter 5 – Chess Dictionary Validator [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 9 months ago. Improve this question First post, new to programming and having fun! All feedback on this post and my questions are welcome. I’m working
Why does it ignore my continue in the for-loop? [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 3 years ago. Improve this question