# \[Solved\] How can i Generate a random number without repeat

**URL:** <https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046>\
**Category:** Questions about Thunkable X\
**Tags:** solved, question, random-number, non-repeating\
**Created:** [February 20, 2020, 11:49am UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046 "2020-02-20T11:49:39Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![3bdoamir1](https://avatars.discourse-cdn.com/v4/letter/3/5f9b8f/32.png) [@3bdoamir1](https://community.thunkable.com/u/3bdoamir1)\
**Post date:** [February 21, 2020, 9:55am UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/21 "2020-02-21T09:55:30Z")

</div>

Your blocks change btn to (1.2.3.4. empty )  
i dont want in row  
in mine it get what exacty i want and some times say undefined i dont know why  
first time work second time undefiend

 ![random list](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/6/c66720be6e8b48f586941486271e8a6c825d67ae.png)

---

<div class="post-metadata">

**Author:** ![3bdoamir1](https://avatars.discourse-cdn.com/v4/letter/3/5f9b8f/32.png) [@3bdoamir1](https://community.thunkable.com/u/3bdoamir1)\
**Post date:** [February 21, 2020, 4:41pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/22 "2020-02-21T16:41:41Z")

</div>

Thanks all for Help  
thats to Make a random number

 ![random number](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/e/be884eee47a35b653a9bfb42ea76fa1c0b783559.jpeg)  
for test  
[https://x.thunkable.com/copy/8a144ddb1998bb84707d282c667a58af](https://x.thunkable.com/copy/8a144ddb1998bb84707d282c667a58af)

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [February 21, 2020, 7:04pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/23 "2020-02-21T19:04:48Z")

</div>

I think the problem was that you incorrectly copied my example.

---

<div class="post-metadata">

**Author:** ![3bdoamir1](https://avatars.discourse-cdn.com/v4/letter/3/5f9b8f/32.png) [@3bdoamir1](https://community.thunkable.com/u/3bdoamir1)\
**Post date:** [February 21, 2020, 7:21pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/24 "2020-02-21T19:21:29Z")

</div>

i gave you a pick with what i did … it works fine in first test when i open the app again it get undefiened  
it worked well then undefiend in last btn click

maybe i did something wrong but this what i did with ur idea

> [@3bdoamir1](#):
>
> ![random number](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/e/be884eee47a35b653a9bfb42ea76fa1c0b783559.jpeg)

what i want to say my problem is solved at least

---

<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:** [February 21, 2020, 10:52pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/25 "2020-02-21T22:52:52Z")

</div>

You get undefined because your list runs out. It’s not an error in the code. It was for example purposes. You would need to add logic to not perform the task of the list is empty.

I will post a slightly different example later today that won’t produce this error.

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [February 22, 2020, 9:16am UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/26 "2020-02-22T09:16:39Z")

</div>

One of the problems with Thunkable X is that It doesn’t allow you to create blocks from images (unlike App Inventor) and you need to manually create blocks. You did this, but you made a mistake. I think you might be interested in finding this bug yourself to develop mindfulness. If this is not interesting, then you can assume that my example worked incorrectly and forget it.

---

<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:** [February 22, 2020, 3:47pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/27 "2020-02-22T15:47:15Z")

</div>

I think this will work for you. Please study the blocks and consider why I placed them in their locations.

please note, that i only add them no another list for demonstration purposes to show how values get removed and that they do still exist somewhere meaning you could take that number _ **not** _ put it into a list and use it elsewhere in your app.

[https://x.thunkable.com/copy/0804620ab5d60ec284a08a17dd13de4d](https://x.thunkable.com/copy/0804620ab5d60ec284a08a17dd13de4d)

 ![Screen Shot 2020-02-22 at 10.32.02 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/9/d99f0f6faed1a5f0f3d7cecf04f8b64f41c2153b.png)

I have modified the title of this post as there have been multiple solutions put forth. 👐 Great work Thunkers!!!

---

<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, 11:40am UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/28 "2024-11-08T11:40:53Z")

</div>

Closed on November 8, 2024, 11:40am UTC



[Previous page](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046.md?page=1)
