- 4

What would be the result of this code if not 6? nums=[9,8,7,6,5] nums.append(4) nums.insert(2,11) Print(len(nums))

26th Aug 2016, 3:00 PM
harkirat singh
harkirat singh - avatar
8 ответов
+ 4
nums.append(4) addes a 4 to the end of your list whereas nums.insert(2, 11) adds 11 to the place that is the second item in the list. So it'd be [9,8,11,7,6,5,4] The answer is 7 because there are now 7 items in the list.
7th Sep 2016, 5:34 PM
trevor badesheim
trevor badesheim - avatar
+ 3
7 of course. Both, append() and insert(), add a member to the array, not replace an existing one.
26th Aug 2016, 4:16 PM
Doc
Doc - avatar
+ 2
7
28th Aug 2016, 7:41 PM
Christoph Stieglitz
Christoph Stieglitz - avatar
+ 1
The answer is 7 because there are now 7 items in the list.
2nd Jul 2020, 1:11 PM
Amani TC
Amani TC - avatar
0
What is the result of this code? nums = [9, 8, 7, 6, 5] nums.append(4) nums.insert(2, 11) print(len(nums)) 7 is the right answer
4th Jul 2019, 10:36 AM
Ubaydullah Rawat
Ubaydullah Rawat - avatar
0
7
4th Jul 2019, 10:37 AM
Ubaydullah Rawat
Ubaydullah Rawat - avatar
0
7
24th Jan 2020, 6:20 AM
THILAGAVATHI J SACAS
THILAGAVATHI J SACAS - avatar
0
7
18th Jul 2022, 1:39 PM
wessam lahmod