AI Club
AI Club
Python with AI –
Introduction to Lists
Lists in Python
• A list holds ordered collection of items.
• This is represented by comma separated values
• Print items in a list
Lists in Python
• A list holds ordered collection of items.
• This is represented by comma separated values
• An item can be a string or a number or anything else 
Lists in Python
• An item can be a string or a number or anything else 
• Think about how you would specify a shopping list if there was no
concept of lists in python?
Lists in Python
• An item can be a string or a number or anything else 
• Think about how you would specify a shopping list if there was no
concept of lists in python?
• You might have to specify one variable for each item and then use
something else to tie all these variables together
Concept of index in a List
• An item can be a string or a number or anything else 
• Each item in the list has a index
• Index in python starts with 0
0 3
2
1 4
Index =
Concept of index in a List
• An item can be a string or a number or anything else 
• Each item in the list has a index
• Index in python starts with 0
• How is this index useful?
0 3
2
1 4
Index =
Concept of index in a List
• An item can be a string or a number or anything else 
• How is this index useful?
• Index tells you the position of the item. Example – 0th item in the list
shoplist is ‘apple’, 1st items is 50 etc
0 3
2
1 4
Index =
Lists inside lists
• An item inside a list can be another list
Access an item in a list
• An item inside a list can be another list
• How can you access the item mouse?
Exercise
• An item inside a list can be another list
• How can you access and print the item mouse
• Use the index to access the item
Exercise
• An item inside a list can be another list
• How can you access and print the item mouse
• How can you access and print the item [‘a’] ?
Exercise
• An item inside a list can be another list
• How can you access and print the item mouse
• How can you access and print the item [‘a’] ?
• How can you access and print a?
Exercise
• An item inside a list can be another list
• How can you access and print the item mouse
• How can you access and print the item [‘a’] ?
• How can you access and print a?
THANK YOU
https://aiclub.world
info@pyxeda.ai

Introduction to lists

  • 1.
  • 2.
    AI Club Python withAI – Introduction to Lists
  • 3.
    Lists in Python •A list holds ordered collection of items. • This is represented by comma separated values • Print items in a list
  • 4.
    Lists in Python •A list holds ordered collection of items. • This is represented by comma separated values • An item can be a string or a number or anything else 
  • 5.
    Lists in Python •An item can be a string or a number or anything else  • Think about how you would specify a shopping list if there was no concept of lists in python?
  • 6.
    Lists in Python •An item can be a string or a number or anything else  • Think about how you would specify a shopping list if there was no concept of lists in python? • You might have to specify one variable for each item and then use something else to tie all these variables together
  • 7.
    Concept of indexin a List • An item can be a string or a number or anything else  • Each item in the list has a index • Index in python starts with 0 0 3 2 1 4 Index =
  • 8.
    Concept of indexin a List • An item can be a string or a number or anything else  • Each item in the list has a index • Index in python starts with 0 • How is this index useful? 0 3 2 1 4 Index =
  • 9.
    Concept of indexin a List • An item can be a string or a number or anything else  • How is this index useful? • Index tells you the position of the item. Example – 0th item in the list shoplist is ‘apple’, 1st items is 50 etc 0 3 2 1 4 Index =
  • 10.
    Lists inside lists •An item inside a list can be another list
  • 11.
    Access an itemin a list • An item inside a list can be another list • How can you access the item mouse?
  • 12.
    Exercise • An iteminside a list can be another list • How can you access and print the item mouse • Use the index to access the item
  • 13.
    Exercise • An iteminside a list can be another list • How can you access and print the item mouse • How can you access and print the item [‘a’] ?
  • 14.
    Exercise • An iteminside a list can be another list • How can you access and print the item mouse • How can you access and print the item [‘a’] ? • How can you access and print a?
  • 15.
    Exercise • An iteminside a list can be another list • How can you access and print the item mouse • How can you access and print the item [‘a’] ? • How can you access and print a?
  • 16.