Week 4 of Intro to Programming @ Udacity!

Welllllllllll wellllllllll wellllllllllllll... everything was going really smooth until I landed on Python substrings. Like, I get it, it makes sense, but I am trying to grasp the entire logic of slicing, and writing this all out inside of a function. We learned how to locate a substring, that was clear. If it is a substring, it's a slice, was the motto they taught us! We created a function that would check if one string is a substring of another. It shall return True or false (boolean), so it was pretty clear. We used string[0:1] after assigning a string to a variable. I get all of that. After all of this, we learned how to 'Generalize all of this'... which removed the hard-coded values. Cool. Next, we learned that this string[0:1] can be written as string[0 : 0 + 1]. With the 1 being a value that is being hard-coded... so we then assigned this value of 1 to a variable len(substring). That was still cool. So here is the code:

def is_substring(substring, string):
index = 0
while index < len(string):
if string[index : index + len(substring)] == substring:
return True
index += 1
return False

So I understand most of this, it's the string[index : index + len(substring)] == substring part --- that I can come to grasp of writing on my own, and also comprehend what my intentions are! I go blank and I am not sure if I understand it totally? We also had a counting_substrings problem after this, it was a total of 3 lessons filled with amazing questions and problem sets for my lovely brain! I got through it, but I don't like how I feel about it, in terms of my confidence in understanding it totally. I hate to move forward without a strong grasp on what I just attempted to learn. Tomorrow, I will re-do these 3 lessons and try to gain more clarification! Awl how I love Python and learning this stuff! I love how it makes you think so hard. Haha! It's pretty fun though, I love problem solving! And the teachers at Udacity are a class of their own! (SUPERB)!! After this, I will move on to 8 hours of Style and Structure! Then I will prepare for my project! In the meantime, I am working on another project, or at least I just set up the Git to start working! It's from Front End Mentor and I am building a QR Component model, using HTML and CSS! That should be fun and keep me busy and learning!

Comments