How do I read 1 value from a list
LukeShomper (42)

Can Pop(0) be used or something like Getting 1 value from a list
or should I use something like
Tea = ["Bob", "Ross", "Has", "Tea"]
And like print(FromTeaGet(0))
And then the console would say
Bob
And if I did print(FromTeaGet(1))
The console would say
Ross
I have googled it and am still confuused

You are viewing a single comment. View All
mwilki7 (865)

If you want to get a value from a list use brackets list[index]
Popping from a list means removing either from the front or back of the list (depending on how the list is coded)

        Mage[0] Mage[1] Mage[2] Mage[3]
            |       |       |       |
            |       |       |       |
            v       v       v       v
Mage = [    100,    100,    50,     50]


                Mage[0] Mage[1] Mage[2]                     new list of size 1
                    |       |       |                               |
                    |       |       |                               |
                    v       v       v                               v
Pop(): Mage = [    100,    100,    50]   Popped the end off! -->  [50]
LukeShomper (42)

@mwilki7 Kinda confused would It be
mage.list[index]
or is it mage[index]
bit confused
because I don't know the syntax trying to figure it out

LukeShomper (42)

Like, give me an example; Code so I can copy past and see how it works and like learn something new :D

mwilki7 (865)

Say you want to show everything inside the mage list (make sure the spelling/capitalization is correct):

for item in Mage:
    print(item)

Or using a for range loop

for i in range(0, len(Mage)):
    print(Mage[i])

Or maybe you just want to get something from a certain index:

myHP = Mage[0]