<jupyter_start><jupyter_text>Inquiry:  Manipulating Strings in Python / Jupyter **The problem**:  Strings -- what are they good for?  How do they work?  Why do programming languages distinguish between "strings" and, say, "integers"?  When I work on code to collect or parse data science information, I feel as though my imperfect knowledge of how variables work gets in the way.  So I'd like to work through some spur-of-the-moment exercises, asking questions, looking up information online, and testing, testing, testing my working hypotheses.**Spoiler alert**:  The answers are not what really matters here.  Instead, *it is the questions that matter*, together with your imaginative and on-going efforts to engage with those questions on an intuitive, engaged level. This publicly-accessible page in my Jupyter Notebook is an excellent place to carry out my inquiry, and then to reshape that effort and share it with the world at large. **Why is this worth doing?**  In part because, to my mind, *it is an exceptionally rich and rewarding form of learning*:  The 20th C. Swiss philosopher Piaget advocated that schools become places for "learning without a curriculum."  That is, for learning that was *directed by students themselves*, and not by clueless institutions or hopelessly-out-of-date instructors; learning that served a student's private purposes, and in so doing helped to encourage her to define her world *on her terms*; learning that is *agile* and *adaptative* and *idiosyncratic* and *situated* because we 21st Century folk are fickle, and bored, and distracted, but we are prodigiously creative, and playful, and worlds are born with just the wave of a hand.  Look:  All of this can still be "rigorous" and "accountable."  It can still be part of a practical education that is useful to us as workers, citizens, thinkers, *and* human beings.  *But let us be done with the mindless fantasy that "rigorous" and "state-sanctioned" have ever meant the same thing.*  Google Seems Like a Good Place to Start So if I'm going to understand strings better, I'm going to need to begin with some authorative insight.  Google for Education (Python) suggested itself.  It seems like a haphazard initiative -- sometimes they seem to be addressing working developers, and sometimes they seem to be aiming at students and educators.  Given the weird dynamics of the computational education space, it's a good bet that by now, *Google for Education* doesn't really know what it is.But they offer this fairly concise introduction to strings in Python.  Here are some of the assertions that they make about Strings, together with the experiments I conduct to understand what they mean.  In effect, doodles in the margins of a textbook. This sentence alone offers plenty to chew on.> Characters in a string can be accessed using the standard [ ] syntax, and like Java and C++, Python uses zero-based indexing, so if str is 'hello' str[1] is 'e'. Their example is too short to be useful, so I've got to get to work:<jupyter_code>s = 'hi'
print (s[1])
print (len(s))
print (s + ' there')<jupyter_output>i
2
hi there<jupyter_text>Point the first:  The original version of that code (without parentheses) actually fails on my machine because I'm using Python3.  So:  Fail Whale.  Or Fail Python.  Whatever.   That 'hi' is a terrific example, though, right?  Some modest experiments, then:<jupyter_code>myString = "Alphabet soup"
print(myString[6] + myString[7])<jupyter_output>et<jupyter_text>If a string variable has a pair of square brackets attached, then the number inside those brackets means "letter number."  But here's the rub:  *Python is a "zero-based" indexing language*, which means that Python starts counting from ZERO, not from ONE as is (typically) the human custom.  Logical?  Sure.But is it practical?  *HELLS NO:  Confusing from here to the end of time.*<jupyter_code>myString2 = myString[9]+myString[10]+myString[11]+myString[12]
myString3 = myString2 + ', ' + myString2
print(myString3)
print(myString3 * 3)
print(myString[0])<jupyter_output>soup, soupsoup, soupsoup, soup
A<jupyter_text>So you'd expect that myString[1] would give us an "A", and myString[2] an "l", and myString[3] a "p", and so on.  But you'd be wrong.So let's see if I have this:<jupyter_code>myString = "12345"
print(myString[0])
print(myString[1])
# LOL

# Wait:  Can I add strings?
a = myString[2] + myString[3]
# a = "3" + "4", right?
print(a)
# LOLCATS<jupyter_output>1
2
34<jupyter_text>So strings are definitely not the same as integers.  The computer sees them differently.<jupyter_code>myString = 'MAGA!' # 'Cause why not?
print(myString[3]+myString[2]+myString[1]+myString[0])<jupyter_output>AGAM
{'fraction_non_alphanumeric': 0.07517035775127769, 'fraction_numerical': 0.010008517887563885, 'mean_word_length': 4.953105196451204, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '251987', 'license': 'MIT', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1297, 'n_words': 674, 'path': 'Personal Jupyter Journyl.ipynb', 'repo_name': 'LeMasters/Jupyter_Tutyr', 'size': '4696'}