MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/PythonLearning/comments/1msspug/whats_wrong/n9drpdy/?context=3
r/PythonLearning • u/Nearby_Tear_2304 • Aug 17 '25
45 comments sorted by
View all comments
Show parent comments
2
range(n) goes from 0 to n-1.
2 u/HotLaMon Aug 17 '25 range(n)What is n?n = len(l)What is the length of l? 5n = 5print(l[n]) = print(l[5])What is the element at index 5? Nothing. Out of range error.range(n) going from 0 to n-1 has nothing to do with the fact that OP is trying to access an index that doesn't exist. 0 u/AwkwardBet5632 Aug 17 '25 Yes, and OP’s error has nothing to do with the comment I was replying to, which it claiming a problem with the range. 2 u/earchip94 Aug 18 '25 Wasn’t stating it was an issue with the range. Was stating it’s an issue with their usage of n. I see how that could’ve been more clear in my first comment.
range(n)
What is n?n = len(l)What is the length of l? 5n = 5
print(l[n]) = print(l[5])What is the element at index 5? Nothing. Out of range error.
range(n) going from 0 to n-1 has nothing to do with the fact that OP is trying to access an index that doesn't exist.
0 u/AwkwardBet5632 Aug 17 '25 Yes, and OP’s error has nothing to do with the comment I was replying to, which it claiming a problem with the range. 2 u/earchip94 Aug 18 '25 Wasn’t stating it was an issue with the range. Was stating it’s an issue with their usage of n. I see how that could’ve been more clear in my first comment.
0
Yes, and OP’s error has nothing to do with the comment I was replying to, which it claiming a problem with the range.
2 u/earchip94 Aug 18 '25 Wasn’t stating it was an issue with the range. Was stating it’s an issue with their usage of n. I see how that could’ve been more clear in my first comment.
Wasn’t stating it was an issue with the range. Was stating it’s an issue with their usage of n. I see how that could’ve been more clear in my first comment.
2
u/AwkwardBet5632 Aug 17 '25
range(n) goes from 0 to n-1.