# How to Print each element of two dimensional array

**URL:** <https://forums.unrealengine.com/t/how-to-print-each-element-of-two-dimensional-array/1324085>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [October 6, 2023, 9:27am UTC](https://forums.unrealengine.com/t/how-to-print-each-element-of-two-dimensional-array/1324085 "2023-10-06T09:27:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RyuFuru12121](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyuFuru12121](https://forums.unrealengine.com/u/RyuFuru12121)\
**Post date:** [October 6, 2023, 9:27am UTC](https://forums.unrealengine.com/t/how-to-print-each-element-of-two-dimensional-array/1324085/1 "2023-10-06T09:27:19Z")

</div>

Hi,

I would like to output an element of two rows by turn in two dimensional array using Print function.

Please look at the following Verse code. In For Statement, I prepare two dimensional array and try to output an element of the First row then output the one of the second row. I expected that print result is;

Reading:Q1  
Judge:Card001  
Reading:Q3  
Judge:Card003  
…  
(Print Order of the Column is random because using Random function)

However, when starting Fortnite, the result is as following picture:

 ![スクリーンショット 2023-10-05 203827](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/a/d/3ad950e6d0b5a763b852965b0f799d33cf71ac30.jpeg)

I do not make sense why the same element is printed more than one time and the second row’s element (Card001, Card002…) is not printed correctly.

Please tell me how to print a result as I expected.

Thank you,

```auto
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Random }
using { /Verse.org/Verse }
using { /UnrealEngine.com/Temporary/UI }
using { /Fortnite.com/UI }
using { /Verse.org/Colors }

# See https://dev.epicgames.com/documentation/en-us/uefn/create-your-own-device-in-verse for how to create a verse device.

# A Verse-authored creative device that can be placed in a level
Source := class(creative_device):

    # array in which Question & Judge elements are set
    var ReadingCards: [][]string = array{array{"Q1", "Card001"},array{"Q2", "Card002"},array{"Q3","Card003"}, array{"Q4","Card004"}, array{"Q5","Card005"}}

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        Sleep(3.0)
        # Shuffle the array for Game
        var ShuffledReadings : [][]string = array{}
        set ShuffledReadings = Shuffle(ReadingCards)
        # Game Start
        Sleep(3.0)
        if (NumberOfColumns : int = ShuffledReadings[0].Length):
            for(Row := 0..ShuffledReadings.Length-1, Column := 0..NumberOfColumns):
                # Print the first row's elements｛Ｑ1, Q2....Q5｝one by one
                if (Question := ShuffledReadings[Row][0]):
                    Print("Reading:{Question}")
                # Print the first row's element｛Card001, Card002....Card005｝one by one
                if (Judge := ShuffledReadings[1][Row]):
                    Print("Judge:{Judge}")

```

---

<div class="post-metadata">

**Author:** ![LloretMunoz](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lloretmunoz/32/725856_2.png) [@LloretMunoz](https://forums.unrealengine.com/u/LloretMunoz)\
**Post date:** [October 6, 2023, 2:51pm UTC](https://forums.unrealengine.com/t/how-to-print-each-element-of-two-dimensional-array/1324085/2 "2023-10-06T14:51:07Z")

</div>

I’m not sure what you want to do but if i understood it well is as simple as change the last if statement to the next i show you:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/d/0/cd00ac011926a22148273a4b3d2cdaaa556dee91.png)

I show you the output it display to check if it is correct:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/0/5/505e30d5ee255bb029aec66e97ff0ff324945057.jpeg)

And if you want to do it the amount of times of your array lenght you should remove the 2nd statement of your loop, like this:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/9/c/99c45380058e8c15f5e6d8c37b05588023f21e93.png)

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [November 5, 2023, 2:51pm UTC](https://forums.unrealengine.com/t/how-to-print-each-element-of-two-dimensional-array/1324085/3 "2023-11-05T14:51:20Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
