python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

python

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

3rd Aug 2020, 3:00 PM
D구산중학교원인성
D구산중학교원인성 - avatar
10 Answers
+ 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)
3rd Aug 2020, 3:31 PM
Rohit Kh
Rohit Kh - avatar
+ 8
The second element of b
3rd Aug 2020, 3:27 PM
Rohit Kh
Rohit Kh - avatar
+ 7
The second element of b
3rd Aug 2020, 3:21 PM
Julia Shabanova
Julia Shabanova - avatar
+ 6
It would always be a good and helpful idea, if the question will be completed by the related code. Thanks!
3rd Aug 2020, 5:04 PM
Lothar
Lothar - avatar
+ 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.
3rd Aug 2020, 5:10 PM
Vinayak Pandey
Vinayak Pandey - avatar
+ 3
thanks to answer
3rd Aug 2020, 3:23 PM
D구산중학교원인성
D구산중학교원인성 - avatar
+ 3
The second element of b
3rd Aug 2020, 3:30 PM
Bot
Bot - avatar
+ 3
why b[1] is second element of b?
3rd Aug 2020, 3:31 PM
D구산중학교원인성
D구산중학교원인성 - avatar
+ 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....
3rd Aug 2020, 6:43 PM
Shashi Nirala
Shashi Nirala - avatar
+ 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
4th Aug 2020, 6:48 AM
Black Coder...
Black Coder... - avatar