python | SoloLearn: Learn to code for FREE!

+4

python

What does c=a+b[1] mean by b[1]?

8/3/2020 3:00:54 PM

D구산중학교원인성

11 Answers

New Answer

+15

D구산중학교원인성 if b is a list then it's second, because array/list index starts with zero so... if b = [7,5,3,6] b[0] gives 7(that is our first element in b) b[1] gives 5(which is our second element in b)

+8

The second element of b

+7

The second element of b

+6

It would always be a good and helpful idea, if the question will be completed by the related code. Thanks!

+4

Here a is variable and b is list b[1] means second element of list And a + b[1] means they are adding it or concatinating it For ex a = 5 b = [1, 2, 3, 4, 5.....] here, b[0] = 0 (because index start with 0) So, b[1] = 2 And, a + b[1] = 5 + 2 = 7 Hope You understood.

+3

thanks to answer

+3

The second element of b

+3

why b[1] is second element of b?

+3

D구산중학교원인성 becouse b is list so that indexing is start from 0 that is , first element has index 0 , second element has index 1 , third element has index 2 and so on....

+3

If b is an array then, It's first position can be called as b[0] For ex. If array b has value [2,3,4] Then b[0] is 2 and it runs same through array like b[1] must be 3 in this case and same b[2] will be 4

+2

It is covered in the Python course here: https://www.sololearn.com/learn/Python/2431/ The first element has the index 0, the second element the index 1 and so on....