Hi all,
I'm fairly new to Python as a language but have some experience with C# and Javascript, so this may be a basic question.
I'm trying to count how many times a single character appears in a multi-dimensional array from a decided start and finish point within the array, and then assign this counted value to a variable. For example:
array1 = [['a', 1],['a', 4],['b', 3],['c', 4]]
I would then want to assign variable 'x' how many times a character like 'a' appears in the array from the starting position only to the third position in the array. My attempts at this are:
x = array1[0:2].count('a')
x = ('a' in array1[0:2]).count
x = count('a', beg= 0, end=2(array1))
I understand the solution may use indexing or something similar? I'm still new to the language and am struggling a little with the syntax, so apologies if the answer is blatantly obvious or I've misinterpreted something
Any help is much appreciated :)
Thanks