# Unit 3 - Lesson 27 - Can you randomize objects

**URL:** <https://forum.code.org/t/unit-3-lesson-27-can-you-randomize-objects/38016>\
**Category:** Coding and Debugging Help\
**Tags:** csd-unit-3\
**Created:** [April 24, 2023, 2:55pm UTC](https://forum.code.org/t/unit-3-lesson-27-can-you-randomize-objects/38016 "2023-04-24T14:55:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcraig](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@dcraig](https://forum.code.org/u/dcraig)\
**Post date:** [April 24, 2023, 2:55pm UTC](https://forum.code.org/t/unit-3-lesson-27-can-you-randomize-objects/38016/1 "2023-04-24T14:55:59Z")

</div>

I have a student that wants to randomize what objects are chosen for her game. For ex: She has a list of fruits: apple, banana, orange, watermelon - when the player presses the space bar a fruit is picked. Is there a way to do this?

---

<div class="post-metadata">

**Author:** ![mwood](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mwood/32/4941_2.png) [@mwood](https://forum.code.org/u/mwood)\
**Post date:** [April 24, 2023, 3:59pm UTC](https://forum.code.org/t/unit-3-lesson-27-can-you-randomize-objects/38016/2 "2023-04-24T15:59:47Z")

</div>

@dcraig,

Yes, that can be done. Here’s an example. IT doesn’t use the spacebar, but I’m guessing by looking at this, your student can get an idea of how they might accomplish what they want to.

[Random Animation](https://studio.code.org/projects/gamelab/0ZaBlMesBHJIXeg3-JsTrH10ea3rLWIgpx5VFlsx0PM)

Mike

---

<div class="post-metadata">

**Author:** ![dcraig](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@dcraig](https://forum.code.org/u/dcraig)\
**Post date:** [April 24, 2023, 4:14pm UTC](https://forum.code.org/t/unit-3-lesson-27-can-you-randomize-objects/38016/3 "2023-04-24T16:14:43Z")

</div>

Thank you. This will be helpful.
