def change(Is): Is[1] = 8 Ist = [5,6] change(Ist) print(sum(Ist)) | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

def change(Is): Is[1] = 8 Ist = [5,6] change(Ist) print(sum(Ist))

Can anyone describe to me? How it's working?

28th Aug 2020, 3:12 PM
Abhishek Kumar
Abhishek Kumar - avatar
5 ответов
+ 4
When we are calling the function with the lst as input. It does: Change the 2nd element of the input to 8 So now the second element of the lst becomes: 8 And hence the list changes to: [5,8] And the last line is just to show the sum of all the elements in the lst: Hence, 5+8 = 13
28th Aug 2020, 3:15 PM
Namit Jain
Namit Jain - avatar
+ 4
Use correct relevant tag .you mentioned cpp but you posted question in Python language 😱🤔
28th Aug 2020, 3:47 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
I guess your concepts are not clear! ls is the input provided to the function! It can be any value, but in this case it is lst https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2286/
28th Aug 2020, 3:22 PM
Namit Jain
Namit Jain - avatar
0
How it's changed to 8? "Is and Ist" are related to?
28th Aug 2020, 3:20 PM
Abhishek Kumar
Abhishek Kumar - avatar
0
Sorry!
28th Aug 2020, 3:52 PM
Abhishek Kumar
Abhishek Kumar - avatar