Data Type
Lists can contain any mix and match of the data types you have seen so far.
list_of_random_things= [1,3.4,'a string',True]#integer,float,string,boolean
print(list_of_random_things[0])
# attention it is 'True' not 'Ture'
Print Lists
The location of data
list_of_random_things= [1,3.4,'a string',True]
print(list_of_random_things[len(list_of_random_things)])
# IndexError: list index out of range
list_of_random_things= [1,3.4,'a string',True]
print(list_of_random_things[len(list_of_random_things)-1])
# output:True
Print from last one
>>>list_of_random_things[-1]
True
>>>list_of_random_things[-2]
a string
Print from x->y
>>>list_of_random_things= [1,3.4,'a string',True]
>>>list_of_random_things[1:2]#or[(from the first one to the second if the ''is behind 2 it is the second to the last one):2]
[3.4]
Judge
in or not in
>>>'this'in'this is a string'
True
>>>'in'in'this is a string'
True
>>>'isa'in'this is a string'
False
>>>5notin[1,2,3,4,6]
True
>>>5in[1,2,3,4,6]
False