Modify Lists

In this chapter we are going to learn about the Modify Lists

Introduction

We can create this program quickly using the Quick Start component

ib_quickstart_modifylists.png

Program Steps

After selecting the (Modify Lists) template, we will get the next steps in the Goal Designer

gd_quickstart_modifylists.png

The Steps Tree:

aList = 1:5
For x in aList step 1
        Switch x
                Case 1
                        x = "one"
                Case 2
                        x = "two"
                Case 3
                        x = "three"
                Case 4
                        x = "four"
                Case 5
                        x = "five"
        End of Switch
End of For Loop
Print aList

Creating the Program

To create this program we will use the next components

  • Assignment

  • For In Loop

  • Switch

  • Case

  • Print Text

In the begining the Steps Tree is empty

1.png

Select the (Assignment) component

2.png

Enter the data in the Interaction Page

Left side: aList

Right side: 1:5

This will create a list contains the numbers from 1 to 5

i.e. aList = [1,2,3,4,5]

3.png

The Steps Tree will be updated

4.png

Select the (For In) component

5.png

Enter the data in the Interaction Page

Variable: x

In: aList

Step: 1

6.png

The Steps Tree will be updated

7.png

Select the (Switch) component

8.png

The variable will be (x)

9.png

We will update each list item based on the item number

10.png

if the item number is 1, set the item value to “one”

11.png 12.png 13.png 14.png 15.png 16.png

if the item number is 2, set the item value to “two”

17.png 18.png 19.png 20.png 21.png 22.png 23.png

if the item number is 3, set the item value to “three”

24.png 25.png 26.png 27.png 28.png

if the item number is 4, set the item value to “four”

29.png 30.png 31.png 32.png 33.png 34.png

if the item number is 5, set the item value to “five”

35.png 36.png 37.png 38.png 39.png 40.png 41.png 42.png

Now we have the final Steps Tree in our program

43.png