Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

loops

What is the difference between range and xrange functions in Python 2.X?

August 21, 2022 by Magenaut

Apparently xrange is faster but I have no idea why it’s faster (and no proof besides the anecdotal so far that it is faster) or what besides that is different about

Categories Python, Q&A Tags loops, python, python-2.x, range, xrange Leave a comment

Iterate through pairs of items in a Python list

August 20, 2022 by Magenaut

Is it possible to iterate a list in the following way in Python (treat this code as pseudocode)? a = [5, 7, 11, 4, 5] for v, w in a: print [v, w] And it should produce [5, 7] [7, 11] [11, 4] [4, 5] Answers: Thank you for visiting the Q&A section on Magenaut. … Read more

Categories Python, Q&A Tags list, loops, python Leave a comment

Breaking out of nested loops

August 20, 2022 by Magenaut

Is there an easier way to break out of nested loops than throwing an exception? (In Perl, you can give labels to each loop and at least continue an outer loop.) for x in range(10): for y in range(10): print x*y if x*y > 50: "break both loops" I.e., is there a nicer way than: … Read more

Categories Python, Q&A Tags loops, nested-loops, python Leave a comment

Removing Item From List – during iteration – what’s wrong with this idiom?

August 20, 2022 by Magenaut

As an experiment, I did this:

Categories Python, Q&A Tags list, loops, python Leave a comment

How to avoid “RuntimeError: dictionary changed size during iteration” error?

August 20, 2022 by Magenaut

I have checked all of the other questions with the same error yet found no helpful solution =/

Categories Python, Q&A Tags dictionary, list, loops, python Leave a comment

Pygame clock and event loops

August 19, 2022 by Magenaut

i am new to pygame and i was wondering what an event loop is and what clock does in this situation, like what is clock.tick(60)? I don’t understand any explanations online

Categories Python, Q&A Tags loops, pygame, python Leave a comment

Traverse a list in reverse order in Python

August 19, 2022 by Magenaut

So I can start from collection[len(collection)-1] and end in collection[0].

Categories Python, Q&A Tags loops, python, reverse Leave a comment

Loop that also accesses previous and next values

August 19, 2022 by Magenaut

How can I iterate over a list of objects, accessing the previous, current, and next items? Like this C/C++ code, in Python?

Categories Python, Q&A Tags iteration, loops, python Leave a comment

Is it possible to implement a Python for range loop without an iterator variable?

August 19, 2022 by Magenaut

Is it possible to do following without the i?

Categories Python, Q&A Tags for-loop, loops, python, range Leave a comment

Loop backwards using indices

August 19, 2022 by Magenaut

I am trying to loop from 100 to 0. How do I do this in Python?

Categories Python, Q&A Tags loops, python Leave a comment
Older posts
Newer posts
← Previous Page1 Page2 Page3 Page4 … Page6 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress