yyy
0
Q:

python list of dictionaries

list1 = ["a", "b" ,"c"] # a bunch of things 
dictionary1 = {"a":1, "b":2, "c":3} # like a list but each part of it has an associated extra bit
1
student_data = {
  "name":"inderpaal",
  "age":21,
  "course":['Bsc', 'Computer Science']
}

#the keys are the left hand side and the values are the right hand side
#to print data you do print(name_of_dictionary['key_name'])

print(student_data['name']) # will print 'inderpaal'
print(student_data['age']) # will print 21
print(student_data['course'])[0]
#this will print 'Bsc' since that field is an array and array[0] is 'Bsc'
3
  new_player1 = { 'firstName': 'LaMarcus', 'lastName': 'Aldridge', 'jersey': '12', 'heightMeters': '2.11', 'nbaDebutYear': '2006', 'weightKilograms': '117.9'}
            new_player2 = { 'firstName': 'LeBron', 'lastName': 'James', 'jersey': '2', 'heightMeters': '2.03', 'nbaDebutYear': '2003', 'weightKilograms': '113.4' }
            new_player3 = { 'firstName': 'Kawhi', 'lastName': 'Leonard', 'jersey': '2', 'heightMeters': '2.01', 'nbaDebutYear': '2011', 'weightKilograms': '104.3' }  
  
  nba_players = []
  nba_players.append(player)
  nba_players.append(new_player1)
  nba_players.append(new_player2)
  nba_players.append(new_player3)
2

New to Communities?

Join the community