
Loops - for i and for j in range (n) explained : r/learnpython
Jul 3, 2021 · I'm a Python beginner and wondering if anyone can explain what the for j in range i line is doing here? In addition, what is the proper name for…
Can someone explain how range () works? : r/learnpython - Reddit
Mar 9, 2024 · Can someone explain how range () works? I've been using range () in for loops and thought range () simply returns a list, tuple or set containing a sequence of numbers. But when I tried …
Reversing a range using a FOR LOOP : r/learnpython - Reddit
Dec 24, 2022 · I'm doing self-study program in Python and I'm being challenged to create a function that act exactly like the RANGE function, but it reverse the range. Let's call it reverserange (). …
I can't understand "len" in "range" : r/learnpython - Reddit
Mar 24, 2022 · So, I started learning python (my first language) with programiz.com I stumbled upon ranges and use of len in. # Program to iterate through a list using indexing genre = ['pop', 'rock', …
Why does 'for i in range' always use the i variable? - Reddit
If you do classic for i in range () loop the i may be considered as an index, because when you want to get the value from the list at i-th index you'll use my_list [i]. This is not very pythonic but if you are …
What's the difference between for i in list: vs for i in range (len ...
Jul 3, 2021 · Sorry this may seem like a super python noob question, but I just started learning and I am stuck on this idea. Why is it that sometimes one makes the code work but not the other? What's the …
range (len (s)) vs enumerate? : r/learnpython - Reddit
May 28, 2021 · Yes. Don't use range(len(s). The #1 reason, but the reason new programmers mostly ignore, is that it's non-Pythonic. It's less clear about what you are trying to do; if you are doing things …
Can a for loop start somewhere other than 0? : r/learnpython
Jun 21, 2022 · Using range and then working with list [i] might not be horribly complicated, but depending on the specifics it's a great way to screw up with off-by-1 errors or unintentionally …
Is there a way to change the value of range in a for loop?
Jun 20, 2023 · As other comments already stated, you can't change the iterator loop of a range object. Beginners often use lists, range, and "for loops" in an "unpythonic" way, what also complicates the …
What difference does range (len ()) make : r/learnpython - Reddit
Apr 1, 2021 · Iterating over range(len(container)) is generally considered un-Pythonic and usually comes from people who learned other programming languages first and then tried to make Python work the …