Why this method don't right? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why this method don't right?

# x.remove(obj) x = [1, 2, 6.06, 9] print(x.remove(1)) How to write, help please?

20th May 2020, 10:16 PM
Blokhin Roman
Blokhin Roman - avatar
3 Answers
+ 4
x = [1, 2, 6.06, 9] x.remove(1) print(x) # "remove" returns "None" so "None is printed (in your code)..
20th May 2020, 10:21 PM
rodwynnejones
rodwynnejones - avatar
+ 3
a=[1,2,3,4] a.reverse() print(a)
20th May 2020, 10:21 PM
Abhay
Abhay - avatar
+ 2
Blokhin Roman remove method doesn't return the removed element but pop() method do so when index number passed to it otherwise it will pop last element of list print (x.pop(0))
21st May 2020, 5:14 AM
Mohd Aadil
Mohd Aadil - avatar