In php I can have an array
$shop["rose"] = array(1 , 15);
$shop["jim"] = array( 5 , 7);
$shop["bud"] = array( 9 , 22);
If I type $shop["jim"] I get the array for Jim. How could I do this in Python?
Thanks Glenn
In php I can have an array
$shop["rose"] = array(1 , 15);
$shop["jim"] = array( 5 , 7);
$shop["bud"] = array( 9 , 22);
If I type $shop["jim"] I get the array for Jim. How could I do this in Python?
Thanks Glenn
You can use Lists and Dictionaries in Python in order to use the same strategy:
shop = {
'rose': [1,15],
'jim': [5,7],
'bud': [9,22]
}
print(shop) # {'rose': [1, 15], 'jim': [5, 7], 'bud': [9, 22]}
print(shop['rose']) # [1, 15]