Learn to Code via Tutorials on Repl.it

← Back to all posts
Reading 1 value from a list PYTHON
LukeShomper (7)

Lists are annoying but really good. Here is a simple example of how to use lists

bob = [0, 4, "Te"]
print(bob)

the output or console should say

[0, 4, Te]

or something like that but here's the thing what if you want it to print 1 value from a list you would do

Tea = ["Bob", "Ross", "Teah"]

and you want it to only print value 3 (Teah) of the list you would do

print(Tea[2])

If you're wondering why I used 2 not 3 it's because lists start at 0. So if your number 1 is 0 and 2 is 1 and so on this confused me at first but then someone helped me with this little method