Strings being used like lists

In Python, for example, it is possible to do this:

for i in "Hello!":
    print(i)

This will print:

H
e
l
l
o
!

However, in Snap, you need to use the Split by Letter block:
untitled%20script%20pic%20(1)
I think that these list blocks should also work for strings, so you don't need to use the Split block.

  • For each
  • Item ... of
  • Contains
  • In front of
  • All but first of
  • Length of

You are pulling at the end of a long thread.

There are two arguments against what you are suggesting. The first one is efficiency: For lists, ALL BUT FIRST OF and IN FRONT OF are constant-time operations. (Footnote: the first time you use one of them, the entire list will be converted from array representation to linked-list representation. But after that, it's constant time.) That wouldn't be the case for strings, so you are better off converting the string to a list if you want to use functional/recursive operations on it. Providing the string operations you want as primitives would be misleading people into thinking the implementation efficiencies are the same for strings and lists. (Of course you're welcome to write your own; they don't have to be primitives.)

The second reason is pedagogic; we want to encourage users to think of text as words and sentences rather than as undifferentiated strings of characters. So really ALL BUT FIRST OF [CAN'T BUY ME LOVE] would be BUY ME LOVE if I were to invent such a block. (In reality, the word-sentence library has blocks ALL BUT FIRST WORD OF and ALL BUT FIRST LETTER OF.)

OK. Thanks for that information.