+ 1

[Python] Any tips for better understanding conditional loops and implementing them?

I’m really getting a better handle on python overall. Still find myself having some trouble mostly with understanding and implementing some loops and checks, like for practice coding exercises. I’ve included some code to return the number of positions where two strings contain the same length 2 substring(had to look up the solution)as an example: https://code.sololearn.com/cB2AYZWCjcGJ/?ref=app I do see why that particular one works(now) So any advice in general on this, I’d greatly appreciate. Thanks.

1st Oct 2019, 9:40 AM
Jacob Sloan
Jacob Sloan - avatar
3 Réponses
+ 3
a_sub = a[1:1 + 2] b_sub = b[1:1 + 2] Looks like you intended to write i instead of 1, is that right?
1st Oct 2019, 9:50 AM
jtrh
jtrh - avatar
+ 1
my bad, yeah im gonna go fix that real quick edit: double checked it and no more typos now.
1st Oct 2019, 9:52 AM
Jacob Sloan
Jacob Sloan - avatar
0
From what I've seen so far, getting the logic right (conditionals, loops) is something like muscle that only grows *slowly* while you train. It's different every time, so you'll write, test, debug, test...
1st Oct 2019, 11:22 AM
HonFu
HonFu - avatar