Did anyone else’s mind get blown learning about nesting loops? /u/PathRealistic6940 Python Education

Did anyone else’s mind get blown learning about nesting loops? /u/PathRealistic6940 Python Education

Edit: It is actually recursion, not nesting loops. Got the label wrong.

So was going through some challenges and got into backtracking. Long story short, I learned about nesting for loops, but not visually. Like this instead.

def find_zero_sum_subset(arr): arr_sub = [] def backtrack(start, current_subset): if sum(current_subset) == 0 and len(current_subset) > 0: arr_sub.append(current_subset) for i in range(start,len(arr)): backtrack(i+1, current_subset + [arr[i]]) return arr_sub return backtrack(0,[])

That’s nuts. It starts a loop in the middle of a loop, in the middle of a loop, n times. Now that i look back on it, it makes sense. Took me a while to wrap my head around this

submitted by /u/PathRealistic6940
[link] [comments]

​r/learnpython Edit: It is actually recursion, not nesting loops. Got the label wrong. So was going through some challenges and got into backtracking. Long story short, I learned about nesting for loops, but not visually. Like this instead. def find_zero_sum_subset(arr): arr_sub = [] def backtrack(start, current_subset): if sum(current_subset) == 0 and len(current_subset) > 0: arr_sub.append(current_subset) for i in range(start,len(arr)): backtrack(i+1, current_subset + [arr[i]]) return arr_sub return backtrack(0,[]) That’s nuts. It starts a loop in the middle of a loop, in the middle of a loop, n times. Now that i look back on it, it makes sense. Took me a while to wrap my head around this submitted by /u/PathRealistic6940 [link] [comments] 

Edit: It is actually recursion, not nesting loops. Got the label wrong.

So was going through some challenges and got into backtracking. Long story short, I learned about nesting for loops, but not visually. Like this instead.

def find_zero_sum_subset(arr): arr_sub = [] def backtrack(start, current_subset): if sum(current_subset) == 0 and len(current_subset) > 0: arr_sub.append(current_subset) for i in range(start,len(arr)): backtrack(i+1, current_subset + [arr[i]]) return arr_sub return backtrack(0,[])

That’s nuts. It starts a loop in the middle of a loop, in the middle of a loop, n times. Now that i look back on it, it makes sense. Took me a while to wrap my head around this

submitted by /u/PathRealistic6940
[link] [comments]  Edit: It is actually recursion, not nesting loops. Got the label wrong. So was going through some challenges and got into backtracking. Long story short, I learned about nesting for loops, but not visually. Like this instead. def find_zero_sum_subset(arr): arr_sub = [] def backtrack(start, current_subset): if sum(current_subset) == 0 and len(current_subset) > 0: arr_sub.append(current_subset) for i in range(start,len(arr)): backtrack(i+1, current_subset + [arr[i]]) return arr_sub return backtrack(0,[]) That’s nuts. It starts a loop in the middle of a loop, in the middle of a loop, n times. Now that i look back on it, it makes sense. Took me a while to wrap my head around this submitted by /u/PathRealistic6940 [link] [comments]

Read more

Ask Anything Monday – Weekly Thread /u/AutoModerator Python Education

Ask Anything Monday – Weekly Thread /u/AutoModerator Python Education

Welcome to another /r/learnPython weekly “Ask Anything* Monday” thread

Here you can ask all the questions that you wanted to ask but didn’t feel like making a new thread.

* It’s primarily intended for simple questions but as long as it’s about python it’s allowed.

If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.

Rules:

Don’t downvote stuff – instead explain what’s wrong with the comment, if it’s against the rules “report” it and it will be dealt with. Don’t post stuff that doesn’t have absolutely anything to do with python. Don’t make fun of someone for not knowing something, insult anyone etc – this will result in an immediate ban.

That’s it.

submitted by /u/AutoModerator
[link] [comments]

​r/learnpython Welcome to another /r/learnPython weekly “Ask Anything* Monday” thread Here you can ask all the questions that you wanted to ask but didn’t feel like making a new thread. * It’s primarily intended for simple questions but as long as it’s about python it’s allowed. If you have any suggestions or questions about this thread use the message the moderators button in the sidebar. Rules: Don’t downvote stuff – instead explain what’s wrong with the comment, if it’s against the rules “report” it and it will be dealt with. Don’t post stuff that doesn’t have absolutely anything to do with python. Don’t make fun of someone for not knowing something, insult anyone etc – this will result in an immediate ban. That’s it. submitted by /u/AutoModerator [link] [comments] 

Welcome to another /r/learnPython weekly “Ask Anything* Monday” thread

Here you can ask all the questions that you wanted to ask but didn’t feel like making a new thread.

* It’s primarily intended for simple questions but as long as it’s about python it’s allowed.

If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.

Rules:

Don’t downvote stuff – instead explain what’s wrong with the comment, if it’s against the rules “report” it and it will be dealt with. Don’t post stuff that doesn’t have absolutely anything to do with python. Don’t make fun of someone for not knowing something, insult anyone etc – this will result in an immediate ban.

That’s it.

submitted by /u/AutoModerator
[link] [comments]  Welcome to another /r/learnPython weekly “Ask Anything* Monday” thread Here you can ask all the questions that you wanted to ask but didn’t feel like making a new thread. * It’s primarily intended for simple questions but as long as it’s about python it’s allowed. If you have any suggestions or questions about this thread use the message the moderators button in the sidebar. Rules: Don’t downvote stuff – instead explain what’s wrong with the comment, if it’s against the rules “report” it and it will be dealt with. Don’t post stuff that doesn’t have absolutely anything to do with python. Don’t make fun of someone for not knowing something, insult anyone etc – this will result in an immediate ban. That’s it. submitted by /u/AutoModerator [link] [comments]

Read more

What was a recent Android feature(s) update that has really made the difference for you? /u/DiplomatikEmunetey Android

What was a recent Android feature(s) update that has really made the difference for you? /u/DiplomatikEmunetey Android

Does not necessarily have to be something big. Just something that was added or changed that has made your interaction with the OS, a more positive experience. Something that you notice.

For me, it was Pixel’s select text, copy links, and images from recents.

Makes text selection super convenient and quick. You can also quickly share a link with someone right from the recents. Or copy an image to paste it somewhere else. Did not think much of it when it was first introduced, in fact, I did not like it at first, and wanted the old, predictive 5 shortcuts back. Now I find this feature so convenient that I don’t know if I would be able to switch to a non-pixel phone because of it.

Also, strangely the Media Picker introduced in Android 13. I remember before it was added, it was being hyped up, and I have to say, it has lived up to it. I use it almost daily, and I really like it. I like its UI and how it integrates third party apps too. So you can use, for example, Simple Gallery to select the image/video. It has search and convenient filtering pills for filtering media types. It’s very well thought out.

submitted by /u/DiplomatikEmunetey
[link] [comments]

​r/Android Does not necessarily have to be something big. Just something that was added or changed that has made your interaction with the OS, a more positive experience. Something that you notice. For me, it was Pixel’s select text, copy links, and images from recents. Makes text selection super convenient and quick. You can also quickly share a link with someone right from the recents. Or copy an image to paste it somewhere else. Did not think much of it when it was first introduced, in fact, I did not like it at first, and wanted the old, predictive 5 shortcuts back. Now I find this feature so convenient that I don’t know if I would be able to switch to a non-pixel phone because of it. Also, strangely the Media Picker introduced in Android 13. I remember before it was added, it was being hyped up, and I have to say, it has lived up to it. I use it almost daily, and I really like it. I like its UI and how it integrates third party apps too. So you can use, for example, Simple Gallery to select the image/video. It has search and convenient filtering pills for filtering media types. It’s very well thought out. submitted by /u/DiplomatikEmunetey [link] [comments] 

Does not necessarily have to be something big. Just something that was added or changed that has made your interaction with the OS, a more positive experience. Something that you notice.

For me, it was Pixel’s select text, copy links, and images from recents.

Makes text selection super convenient and quick. You can also quickly share a link with someone right from the recents. Or copy an image to paste it somewhere else. Did not think much of it when it was first introduced, in fact, I did not like it at first, and wanted the old, predictive 5 shortcuts back. Now I find this feature so convenient that I don’t know if I would be able to switch to a non-pixel phone because of it.

Also, strangely the Media Picker introduced in Android 13. I remember before it was added, it was being hyped up, and I have to say, it has lived up to it. I use it almost daily, and I really like it. I like its UI and how it integrates third party apps too. So you can use, for example, Simple Gallery to select the image/video. It has search and convenient filtering pills for filtering media types. It’s very well thought out.

submitted by /u/DiplomatikEmunetey
[link] [comments]  Does not necessarily have to be something big. Just something that was added or changed that has made your interaction with the OS, a more positive experience. Something that you notice. For me, it was Pixel’s select text, copy links, and images from recents. Makes text selection super convenient and quick. You can also quickly share a link with someone right from the recents. Or copy an image to paste it somewhere else. Did not think much of it when it was first introduced, in fact, I did not like it at first, and wanted the old, predictive 5 shortcuts back. Now I find this feature so convenient that I don’t know if I would be able to switch to a non-pixel phone because of it. Also, strangely the Media Picker introduced in Android 13. I remember before it was added, it was being hyped up, and I have to say, it has lived up to it. I use it almost daily, and I really like it. I like its UI and how it integrates third party apps too. So you can use, for example, Simple Gallery to select the image/video. It has search and convenient filtering pills for filtering media types. It’s very well thought out. submitted by /u/DiplomatikEmunetey [link] [comments]

Read more