# Seperating words from an input

**URL:** <https://community.thunkable.com/t/seperating-words-from-an-input/1280779>\
**Category:** Tutorials and DIY Guides\
**Tags:** community, text, tips\
**Created:** [May 13, 2021, 12:34pm UTC](https://community.thunkable.com/t/seperating-words-from-an-input/1280779 "2021-05-13T12:34:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [May 13, 2021, 12:34pm UTC](https://community.thunkable.com/t/seperating-words-from-an-input/1280779/1 "2021-05-13T12:34:52Z")

</div>

Lots of my apps required dealing with the (x)th word in an input, and counting the number of words in an input, and so on. I thought that would be possible with a block, but turned out you could only count characters. So I tried and tried to devise my own method, and in the end, when I found it, it was surprisingly simple. So here I am writing this post to show you how to do it yourself:

Every word is separated from the other words by a space, and we use that to form our solution.  
For this example, I’m creating an app that tells the user the number of words in his/her text, and the number of characters.

This is my design:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/5/751689d7c38a41beeadbf9dc000756c26de2628a.png)

I have a text input at the top(Title of your story), that doesn’t make any difference. I have another input(Write your story here), and it is from this input’s text that we’ll be using.\

Underneath that, I have a row. In that row is 1 label, called Label Words, with the text 0. The one beside has the text “Words,”. Beside that is another label with the text 0, called Label Characters, and after that is the last label, with the text “Characters”.

Our basic idea is to: make a list from our text input’s text with the delimiter (space), and saving it in a variable. That means we are inserting each word into a list. Then, we need to find out the number of words. Since each word is a separate list item, that means we need to find the length of our list. We also want to display the number of characters. And, we want this all to happen whenever the user writes something new or deletes some text.

Blocks:

Step 1: Initialize an app variable called ‘Characters’ to an empty text box. This is meant to store the number of characters.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/e/4e2211178c29d0378f3cf4162e11267fa2fd34a5.png)

Step 2: Initialize a variable called ‘words’ to an empty list.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/f/6f719c364106ef2166208c959011151e988b994b.png)

Step 3: SInce we want this to display the words and characters _everytime_ the user types something in our input, we will use the When Text Input Changes block.

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/7/e7d05446260e96044225c27cdd8f5331300753ba.png)

Step 4: We want to set out variable ‘words’ to a list made from the delimiter (space).

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/e/6eef66f3f7fb6ba7a897ff7cb5d89e7e1ef0319d.png)

Step 5: We want to display the number of words by displaying the length of our variable.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/7/17b549cc3b095ddfe4bf9cdd5fe6746bb5ecb1b8.png)

Step 6: Now, we want to set our characters variable to the number of characters in the user’s text. This is simple:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/9/8923deba218ee6f33d6472a1a6d1af9a9c77a16d.png)

Step 7: We want to display our variable characters in our label.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/e/6ef04b8e5369f7b849dbebfc8b383a55f50f0e45.png)

And you’re done!

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [May 13, 2021, 12:52pm UTC](https://community.thunkable.com/t/seperating-words-from-an-input/1280779/2 "2021-05-13T12:52:34Z")

</div>

Nice trick with the list.

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [May 13, 2021, 1:38pm UTC](https://community.thunkable.com/t/seperating-words-from-an-input/1280779/3 "2021-05-13T13:38:07Z")

</div>

Thanks for your feedback!

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 13, 2021, 3:16pm UTC](https://community.thunkable.com/t/seperating-words-from-an-input/1280779/4 "2021-05-13T15:16:48Z")

</div>

The “make list from text” / “make text from list” block is one of my favorite blocks! 🙂

Thanks for the tutorial!

Add those blocks to a function with an input and a return block and you can use it anywhere in your code.

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [May 13, 2021, 3:33pm UTC](https://community.thunkable.com/t/seperating-words-from-an-input/1280779/5 "2021-05-13T15:33:51Z")

</div>

> [@tatiang](#):
>
> Add those blocks to a function with an input and a return block and you can use it anywhere in your code.

On that screen, anyway! I soooo want cross-screen functions! 🙂

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [May 13, 2021, 4:17pm UTC](https://community.thunkable.com/t/seperating-words-from-an-input/1280779/6 "2021-05-13T16:17:05Z")

</div>

> [@tatiang](#):
>
> favorite blocks!

Yep, me too! And also (sadly) one of the most unused, and unheard of.  
And, oh, to have cross-screen functions! I suppose there is a reason (component names), but functions with return blocks should be able to do that!

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [May 14, 2021, 11:31am UTC](https://community.thunkable.com/t/seperating-words-from-an-input/1280779/7 "2021-05-14T11:31:15Z")

</div>

@actech posted a way to do this a while back. I’ll see if I can’t find that today!

---

<div class="post-metadata">

**Author:** ![josepandare02t](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@josepandare02t](https://community.thunkable.com/u/josepandare02t)\
**Post date:** [November 25, 2021, 9:17pm UTC](https://community.thunkable.com/t/seperating-words-from-an-input/1280779/8 "2021-11-25T21:17:01Z")

</div>

I have been looking for the way to separate words before searching in database and this is just a great solution. Already implemented it and is simple a fast in the algorith.

Thanks for sharing…

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [November 26, 2021, 4:11am UTC](https://community.thunkable.com/t/seperating-words-from-an-input/1280779/9 "2021-11-26T04:11:17Z")

</div>

Glad it helped you 😀

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:22pm UTC](https://community.thunkable.com/t/seperating-words-from-an-input/1280779/10 "2024-11-08T13:22:29Z")

</div>


